My TDBgrid is showing 1899/12/30 in a Time Field - ms-access

My TDbgrid is displaying "1899/12/30 23:00" in a time field. I have connected the database via a dynamic link , so i cannot change anything via design. I am aware that there is solution to this on StackOverflow but i cannot use the solution because my database is connected dynamically. Is there a way to display the time only.
Thank you.

This is by design, as the "zero date" value of DateTime is Access in 1899-12-30.
Thus, your time value of your sample is 23:00:00.
However, a DateTime value carries no format, so the solution is up to you - apply the format you wish to the value whenever you wish to display the time - in your case, the format will most likely be hh:nn (in VBA, don't know about Delphi).

Related

Inserting a 'day' column in Access

I'm working in Access and currently have a column with a time stamp in the format DD/MM/YYYY hh:mm. I'm trying to insert a column next to it that only contains the relevent day in number format without the rest of the timestamp. I'm sure this is painfully simple but for some reason I can't figure it out.
Many thanks,
Matt
In a query, add the expression:
Day([YourTimestampFieldName])
In a form with a textbox, use this ControlSource for the textbox:
=Day([YourTimestampFieldName])
If relevent day in number format means something else than the day, please specify.
You have multiple options.
You can design to column to be a specific format in the table design view. This will enforce date formats for you. Its been a minute for me, but I believe it even works as you try to insert into that column.
You can use the FORMAT function on inserts, as getting data from another column/data type is what youre doing. its actual specific use is of:
FORMAT(yourColumn, "MM-DD-YYYY")
If you need more specifics, you can google the function.
You can set up a macro that will function like a trigger in normal RDMS's. This i envision will UpSert the value to the new column based on INSERT/UPDATE logic.
Let me know if you think this requires more assistance. I think this should be more than enough to get you started.

Is there a way to change the value of all selected "cells" in the MS Access table gui?

MS Office 365 ProPlus, Access 2007 - 2016
Is there a way to change the value of all the selected cells in an Access table to one, user specified value ? In Excel, this would be similar to selecting a set of cells in a column, changing the value of the first, then "Ctrl-Enter" to change the value in all the selected cells.
I was able to do something along these lines using "replace", but that only works if all the values being replaced are the same and the user is willing to click the replace button for every cell they want the replace to work on. It's a fair solution for this special case.
I can do what I want quite handily using sql. But the average user of this DB will not know SQL. Also, I kinda don't want them throwing SQL at the DB if they don't know what they are doing with SQL (so easy to destroy a lot using so little code).
If it's not that simple, I'd like to welcome any brainstorming on how to do this.

Data type conversion from Access to SQL Server errors

I have a SQL Server that is ODBC into my Access which is being utilized as my front end. I created a column in SQL with a BIT data type and created a checkbox with the yes/no data type that uses my SQL Column as its control source. When I go into my form and try to change anything in there and update my tables, I get a writing error and it wont let me append the updates I'm trying to make. As soon as I delete the bit data type, and the check box, then I am able to again append information to my form. Does anyone know a solution or a way I could utilize the Boolean check boxes to report to my SQL Database so that I could track progress of an order, but still be able to append my records? Also if anyone knows why this is happening I would appreciate the information just for my own notes and understanding.
this image shows the column created in SQL Server
This image shows what it looks like in the ODBC table in Access
This image shows the control source I picked which is from a query that utilizes the names of the form comboboxes, text boxes, and hopefully check boxes
This is image shows what happens after I try to update and and close
Thanks
haven't done this for a long time, but the problem could be related to the numbers that are stored. yes/no in access = -1/0, in sqlsrvr = 1/0 (or similar). you could use an INT field in sqlsrvr which will then store whatever access sends (-1 or 0), or keep the BIT but don't use yes/no in access - create a custom yes/no table where yes=1 and no=0 (or whatever BIT needs) and use the custom table as a lookup table for that field which, when updated will send the appropriate value. hope that's all relevant and makes sense.
So I have been messing around with this and after a few other problems running through SQL, Cabinet Vision (our drafting software with a ancient access database) and crystal reports I came to realize that Access cannot accept null values.
So in my SQL Bit data type column I set the default value as 0 and didn't allow nulls. now it records all my check boxes as true or false. and I no longer have a write conflict.
This most commonly arises when a db is developed in Access and at some later date the tables are exported via ODBC to SQLServer. The Checkbox controls on the Access forms were probably placed there using the 'Available Fields' button on the Access 'Design' ribbon. Before getting into complicated solutions with T-SQL modifications to metadata etc, try simply deleting the checkbox control from the problem Access form. Insert an unbound checkbox to replace it, then use the the Properties dialog to set the relevant SQLServer field as the control source for that checkbox. Usually works.

Access Web Application Data Macro to Sum values in Query and return as variable

I am working on a small application in Access Services on SharePoint to log colleagues leave requests, and I need to work out a data macro to calculate how many days of leave they have remaining from their allowance.
I have a table [Colleagues] with all of the user data, for simplicity I'll reduce it to [Email] and [Allowance] in days. I have another table which stores the requests [Requests] including the number of days to deduct in each approved leave request [Days Requested].
I have set up a query that returns all approved requests for the colleague and I would like to use a data macro that is triggered to run when the colleague logs in. As you cannot use aggregate functions in Web Applications, I am currently using ForEachRecord in the query to total the number of deductible days, however I cannot work out how to return that to a field in the [Colleague] record.
According to the Access help, I should be able to set the value to a LocalVar and use it in expressions as simply as referencing [Deductible Days], however this is not working.
Any help?
I finally worked this out after much tinkering.
In my query I included the [Colleague Email] field as well as the [Days Requested] field, and then when my Application loads it navigates to a form created from the [Colleagues] table. I have modified the Data Source of the form to link the [Email] field in the query results to the [Email] field in the [Colleagues] form.
Following this I was able to create an unbound textbox with the data source =Sum([Days Requested]) referring to the relevant field in the query. Voila! I now have the value to play around with in my application.
Hope that helps, took a lot of fiddling around. No data macros needed after all, but its a method I shall remember in future, opens up a lot of possibilities.
If I understand your situation correctly, I was faced with a very similar problem.
I believe the solution used here will work for you. It involves using a query to Sum up the values (we would use Sum where he used Count), use a Data Macro to run the query and then have have an On Insert/On Update trigger the Data Macro:
http://devspoint.wordpress.com/2014/03/26/validating-data-with-data-macros-in-access-services-2013/
Let me know if this works for you. It worked for me!

SSRS - Is there a way to restrict date/time input parameters to date only? (Not report output field format.)

I am writing an SSRS report that has several parameters including a couple of date fields. I do not want the user to be able to enter time information in either date field, but SSRS only has the Date/Time data type. Is there a way to force these report parameters to act as date only, and can I set a specific format (e.g., dd/mm/yyyy)? I would like to keep the built-in date-picker-calendar functionality.
I do not want to write my own report parameter web page because if I did then this one report would be the odd one out given that all of our other reports (which don't use date parameters) work fine with the built-in SSRS parameter entry functionality.
Perhaps the answer is that you can't do it with the built-in options, but that seems crazy - how could something so obvious have been overlooked?
The Google and Stackoverflow searches I've done only gave me ways to set the format in the report output (actually there are a number of cases where people have asked a question similar to mine and only received answers about setting the output format).
The problem is that you are using parameters that get timestamp information.
For example, if you are using Now() in your expressions- you will be asking for the current date AND the current time. However, if you use Today()- you will only be asking for the current date.
=Today() 'returns date only
=Now() 'returns date and current timestamp
Useful references:
http://msdn.microsoft.com/en-us/library/ms157328(v=sql.90).aspx
http://msdn.microsoft.com/en-us/library/ms157328.aspx
To answer my own question based on research I've done since asking it: it seems it is not possible to control how SSRS handles user entry of date/time values in parameters. If there is a need to restrict to date (or time) only or do cross-field validation then you need to implement your own front-end - which unfortunately for my specific business case doesn't help.
In my experience it has only given me the date and time when the filed you are selecting from contains both date and time. I have found if I am selecting on a date only field then I only get the date in the parameter
There is a way, but it will require you to CAST your date as Varchar(10) in your parameter dataset.
Next,You'll have to choose "Data Type:" as Text under Parameters section.
Again, you'll have to make sure your SQL code re-converts it into date again. I do not prefer this way, but users really wanted to see date without time.
Let me know if you'd like screenshot or more detail.