I am using the Datetimepicker plugin.
when i press the backspace, a single digit should delete but for me the complete date and time gets deleted and replaced with --/--/------:--
Related
I'm setting the control source of text fields to return the value of a function (multiple fields with different filtering conditions). The form has a combo box with a list of years: when the user selects a specific year, the on change event triggers a refresh of all the fields.
My problem is the fields don't show any values unless after combo box's On Change events. I have to click on the form/fields before the values start showing up.
I tried to do form refresh & field's requery but doesn't work.
The text field's Control Source is set to:
=SummaryReport("Projects","G","1",[Forms]![frmSUMMARY_REPORT]![cmbYEARS])
What I'm trying to do is when the user selects a year from a drop down, the fields values are updated & displayed by the On Change event - currently they seem to be updated but are not showing unless I click on the screen and that's when values start showing up in each field.
The method to update calculated fields is Me.Recalc (or myForm.Recalc):
https://learn.microsoft.com/en-us/office/vba/api/access.form.recalc
Try this instead of .Refresh.
Also I think the better event to use is After Update instead of On Change for a combo box.
I'm using command buttons to import excel files into various tables, and I want to track the last time each table was updated (i.e. the last time the command button was clicked and ran successfully).
I've tried doing this by adding a text field next to each command button, and then adding Me.TextField1.Value = Date to the _Click subroutine for each button. This fills in the date correctly, but it doesn't save the value when I close the data base.
How do I keep the date value from resetting every time I reopen the database?
The way I would probably approach this is to add a table to your database that contains a list of all the Excel files you import on a routine basis. You would store the filename of the Excel file in one column, and the updated date in another column.
Then you can use the DLookup() function to pull the updated date into your text box by your command button.
Of course there are many approaches you could take here, but which one is best depends on your specific needs. If it is just you running this application on a single computer, you might find it easier to use the SaveSetting/GetSetting functions to save simple values to the registry.
SaveSetting "ExcelImporter", "sheet2.xlsx", "Updated", Now()
TextField1 = GetSetting("ExcelImporter", "sheet2.xlsx", "Updated")
If you have a lot of spreadsheets, you might consider a list box with two columns, one with the name of the file, and the other with the date it was last updated. Then you could use a single button to run the update, based on the selected file. Lots of options... :-)
Add a Date/Time field to the table you are updating and set the Default Value property of the field to Now(). When new records are inserted, they will automatically have their insert date and time set.
If you are updating existing records, then update this field to Now explicitly.
You can query this date with
Dim lastUpdate As Variant
lastUpdate = DMax("DateFieldName", "TableName")
In addition, you see when each record has been inserted or updated.
TextBox values are not saved permanently, unless the RecordSource of the form has been set to a table or query and ControlSource of the TextBox has been set to a column of the table or query.
You could create a Custom Database Property to hold the last time the button was clicked.
Function getLastTimeClick() As Date
Const PropertyName As String = "LastTimeClicked"
On Error Resume Next
getLastTimeClick = CurrentDb.Properties(PropertyName).Value
If Err.Number = 3270 Then
CurrentDb.Properties.Append CurrentDb.CreateProperty(PropertyName, dbDate, Now)
End If
CurrentDb.Properties(PropertyName).Value = Now
On Error GoTo 0
End Function
Ok, so I'm experiencing some strange behavior in datetimepicker fields in my program. I use Short format usually, and use a pair of them for date range selections.
The problem i'm experiencing is if a user is using the keyboard for input. they can tab and arrow through the field like normal to key in a date. However if the date part they are entering doesn't fill it's section of the mask and then they press enter to activate the formdefault without shifting focus away from that portion of the date, then the value of the DTP when the ok_button.click event is run is whatever value it had in it BEFORE they typed their change.
to give a specific example:
A user tabs into the date field. the default date in the field is today's date, 4/14/2015. They type in 1, arrow to the day, put in 1, then arrow to the year and type 14, then press enter. The reported value of the DTP is going to be 1/1/2015. Had they instead actually typed out 2015, or used the arrow to move to another date part or tab to shift focus to another control, the DTP will auto update to fill in the rest of the year.
The same problem would exist if they had typed in a 1 for the month and then hit enter, but would NOT happen if they put in a 12 for the month.
The only solution I can think of, and I haven't yet tried to implement it because it sounds like a real kludge and would require me to go through at TON of forms in the project, would be to change the keypress event for enter to shift focus to the OK button, and THEN invoke the formdefault.
I will say that most of the datetimepicker fields on my forms are actually contained within a user control, so if this is a property that can be changed in the control or tied to an event in the control, it would make updating much, MUCH easier.
I am currently using Microsoft Visual Studio Express 2013 for Windows desktop with an SQL back-end. I am trying to run an SQL query that will have the date time in format "yyyy-mm-dd." My problem is I need to see all entries from that date. Currently my date time picker keeps giving me a time with my selection. I need to remove the time portion. I tried a couple of solutions from the web but when I try and display the date time picker in a message box to see what the value is it says false. I am not sure how to change the output value in the custom field to remove this. Here is my code.
This is in on my load event:
'date time picker set up
DTPPromiseDate.Format = DateTimePickerFormat.Custom
DTPPromiseDate.CustomFormat = "yyyy-MM-dd"
Then in a button click event, is a message box to display what was selected in the date time picker. I want to get my message box working correctly before I try and run SQL queries with it.
MsgBox(DTPPromiseDate.Value)
-------------------------UPDATE-----------------
This code appeared as I wanted it to but I am still trying to work it into my query.
DTPPromiseDate.Value.ToString("yyyy-MM-dd")
Apply the formatting string that you used in the picker's custom format to the message box text as well.
I've just created default datepicker from the link http://www.androidpeople.com/android-datepicker-dialog-example .Its working fine.But my problem is when i click date button.,it shown up..and i change the date and click cancel button on date alert.Again when i click date button.,it should shown current date..not previously changed date. i.e.i just need to get current date at each click whatever the date change.
my solve method may be not the better:when you call OnDateSetListener(),you should save the first date,so when you chick the cancen button,you shululd recover it