Dates with a wrong format

khurram7x

Registered User.
Local time
Today, 06:01
Joined
Mar 4, 2015
Messages
226
Hi,
According to the requirements, I've to assign Supervisors to a job for specified dates. When I'm trying to do say via VBA, it is saving in a wrong format and i don't understand why it is happening.


Attaching screenshots of, data Form itself, how it is saved the table and screenshot of the code. Could someone help me fix this please??


I'm highlighting in screenshot to show dates are saving in two different formats during this operation, but 'Immediate Window' shows the correct format during code run.


Regards,
K
 

Attachments

  • Form.JPG
    Form.JPG
    34.3 KB · Views: 104
  • Code.jpg
    Code.jpg
    82.3 KB · Views: 116
  • Wrong Format.jpg
    Wrong Format.jpg
    68.1 KB · Views: 102
maybe on your code you can change it to:

Dim d As Date
..
..
for d = CDate(Me.txtFromDate) To CDate(Me.txtToDate)
...
...
next d


on your insert query, try formatting variable d:

"Values (" & Me.EmployeeID & "," & Me.Role_Type & ",#" & Format(d, "mm/dd/yyyy") & "#," & Me.Working_Hours & .....
 

Users who are viewing this thread

Back
Top Bottom