I am having an issue with a datetimepicker field and am wondering if what I want to accomplish can be done or not. I have a datetime field in my 'Customer' table called 'LastVisit'. When the Customer is created, the LastVisit field is empty or null.
When the user enters the edit screen for a customer, if they don't change the LastVisit field and then save the record, it stays empty - - which is what I want it to do. Here is the problem though, if I set the datetimepicker.value in the screen design it stays that date, so eventually the users will need to click forward many months to get to the current month. If I set the datetimepicker.value = today in the Form_load event, then it sets the value and it gets written to the Customer record even if the user does not go into that field.
What I would like to do is have the default date be 'today', but still have it so the LastVisit field will remain empty unless the user sets it. Any ideas on how to accomplish this?
I figured it out. I had set a date as the value in the Properties of the datetimepicker field when I first created the form. I was looking for other ideas and found that I could right click on the 'value' property and reset it to the default, which is the current time. Now it behaves like I want.
Related
I have database with a MariaDB backend and a MS-Access frontend. I have a table with a column with the data type set to "time(6)". In my backend, the column only shows time-values between 00:00 and 23:59. There are no dates in that column.
However, when I open the (linked) table in my Access frontend, it shows date AND time in that column. It always shows the current date and the time value from the backend-table. So if the actual value in the field is "16:25", Access will show "07.02.2023 16:25" (current date in German date format).
I have a form in Access where one can edit the data for a specific recordset. In that form there is also a textbox for the time value. When the textbox is not selected, it will show the correct time (e.g. 16:25). However, as soon as I click into the textbox to edit the time, it will suddenly show date and time (e.g. 07.02.2023 16:25). The format of that textbox is set to "Time, 24h" though.
How can I make the textbox show only the time without date, even when the textbox is selected? Why does my Access frontend interpret the time value as a datetime value?
If I set the property "Show Date picker" of that textbox to "For dates", it will show the date picker after selecting the textbox, despite the fact that the format is set to "Time, 24h". This doesn't make sense to me. Any ideas? Thank you!
I updated the ODBC connection to the table several times, but in my frontend there are still datetime values in the column that should only have time values.
Why does my Access frontend interpret the time value as a datetime
value?
That's by design as Access doesn't have discrete data types for date and time.
You can easily read the time only:
=TimeValue([YourTimeField])
An edit can be done in an unbound textbox. Use the AfterUpdate event of this to write the edited time.
Also, see my article:
Entering 24-hour time with input mask and full validation in Microsoft Access.
Enter in http://demos.krajee.com/date-range and search for: Single date and time picker without range. Then, clear the default date and try to select today date. Nothing appears. It looks that dont work when select "today" date if there is no previous value in the field.
Is not that a bug? I've googled, but nothing appears about this issue.
So, how can I select the "today" date if previously there is no value in the input field?
I guess this is by desing - if the date is the same as previously selected nothing is changed. And because removing the field text does not trigger the underlying js value widget still thinks the date is there.
You can verify it by changing the date by hand and then clicking the calendar icon - marked date is not changed to the new one.
So answering your question:
If previously there was no value you can select today's date without a problem, only if the today's value was there and it was deleted by hand selecting today does not make it reappear.
I have a Date Field and Subform linked by Date (pick a date, all records from that date show up in the subform.)
My problem is that when I pick a date, the most recently accessed record is CHANGED to that date...
I've tried setting Allow Edits on the subform to No but that didn't work. I've fiddled around with a few of the other options to no avail. Is this a simple solution to a simple problem? I have another form with a Date Field and Subform that works just fine, but that one has everything (edits, additions, deletions) set to No.
My ultimate goal is to display all records on a subform by date and delete the selected record.
Thanks!
The field was a bound field, so the table was being edited even though I had Allow Edits set to Off.
I ended up unbinding the field and using queries to (1) display the appropriate records in the subform and (2) delete the selected record. I thought it'd be easier if I could use the bound field, but in the end I would've saved myself some time and headache if I just used queries to begin with.
I am trying to make a filed in my form become invisible if it's value is empty.
What I have is a form with individual records from a table, this has a sub-form which is linked by an ID, and it displays the results of a query.
This has three fields ones is the ID, a number and third is a date, Not all records have a date and therefore for the ones that do not have one I want to completely hide the date label and the empty text box; and make it appear only when a date is specified.
I'm guessing I might have to use some kind of WHILE statement in my query but I'm not sure whether that's right and how to do it.
I would appreciate your advice on this.
Thanks
You can add this code to the subform current event:
If (datafieldname & "") = "" then
datafieldname.visible=false
else
datafieldname.visible=true
End if
Where datafieldname is the name of the data field on the subform. This will only work if your subform layout is not tableview
What I have here is a table with some text fields. I basically put in the name of some students into a table. I got their info from forms that teachers had sent me. When I put their names into the database, I just put the names in based on which form was at the top. Does access track the actual time that a field was put in in such a way that I could sort my text fields by that so that when I give a list of what I just did to someone else, they won't have to sort through the stack of papers to make sure all of the papers are there?
I should add that I need to track this for an individual field, not just for the record. For instance, let me take this one piece of paper I have. When I get it from an outside agency, I then put it into the database with the student's name and some info. I then need to send it to the teachers for them to sign and send back to me. I am on the second part so the record had already been created, but I want to find the date that I entered the Date_signed field basically.
In this example, you set the default value of the dtmEntered field to Now()
p.s. Same answer as HugoLemos but with a pic :)
You can use a Date/Time field with its default value = Now() to store the time each record is created, as already suggested. That approach works fine when only one user can be adding new records, which sounds like your situation.
If you wish to also store the time an existing record is changed, you can do that from a form's before update event.
This example assumes a text box named txtLast_change which is bound to a Date/Time field in the form's record source. The text box does not have to be visible to the user for this to work.
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.txtLast_change = Now()
End Sub
Create a field with a date type and set default value to Now()
As you have discovered, there isn't any way after-the-fact to know when data was entered in to your table, as it's not something that you captured in the first place. As you mentioned in one of your comments, you can determine the order in which you entered new records based on the Id, but knowing when additional data was entered would require more tracking fields.
In the future, you may want to think about a table design along these lines:
Column Name Column Description
ID Record Id
STUDENT_ID Student Id Number
STUDENT_FIRST_NAME Student First Name
STUDENT_LAST_NAME Student Last Name
... Other student info ...
DATE_ENTERED Date/Time entered
DATE_SENT Date/Time sent to teacher
DATE_SIGNED Date/Time signed by teacher
UPDATED_DATE Date/Time record last updated
UPDATED_BY User that made the last update
If it's possible, you could always edit your table and add these datestamp columns. You'd have to allow for null values, as the previous entries wouldn't have a date/time value for some of them, but it would let you track future entries.