I have a date issue with a table that recieves data from a form via insert into sql statements.
I have a form that selects a customer, gives a code and then inputs the details into two tables.
The problem table "LabDespatch" has these fields "[TransID], [DespatchDate], [DateCreated], [CurrentDespatch]" and a linked subtable, linked on TransID that stores the details of the customers that will/have despatched on a particular date.
The current people being despatched to the lab are entered under the [CurrentDespatch] number (automatically via a form button). When the time comes to despatch the current people to the lab, a form button is pushed and the despatched date is updated in the master table and the linked details table.
Then the [CurrentDespatch] for that group is set to false and new group is created under the next group number. At this time the current date is saved to the field [DateCreated] and its [CurrentDespatch] is set to true.
This is done with the following code:
DespatchSql = " INSERT INTO LabDespatch ([TransId], [DateCreated], [CurrentDespatch]) " _
& " VALUES (" & DMax("TransId", "LabDespatch") + 1 & ", #" & CurrentDate & "#, " & True & ") "
CurrentDate is a date variable that is set to the following:
CurrentDate = Format(Date, "dd/mm/yyyy")
The problem is that the date that appears in the table is the wrong way around in the mm/dd/yyyy (like americanized, I am in Australia and want dd/mm/yyyy).
the current date 09/06/2009 appears as 06/09/2009 in the table. Yet the table is set to date/time (format is dd/mm/yyyy), as you can see (above) I format a variable to dd/mm/yyyy to insert in case the computers short date is set wrong.
I have used the # for date literal in the insert into sql statement and have verifed (by adding a watch on the variable and a stop)that the variable does indeed get the correct format 09/06/2009.
As far as I can see I have everything set to the format dd/mm/yyyy in both the forms vb code and the table (and verified that the variable does indeed contain it correctly as 09/06/2009 before its written to the table), yet every stinking time I despatch a group and new master group is created in the table, the [DateCreated] field is always saved wrong i.e. 06/09/2009 (being the 6th of sept 09)
The table is formated right as I can manually input the date correctly, but when its done via code with the insert sql statement its wrong.
The following is an excel export showing how they have been saved, 27-34 have been manually changed in the table the last, 35 shows the sql save and wrongful format:
[TransId][DespatchDate][Datecreated] [CurrentDespatch]
27 21/01/2009 29/05/2009 FALSE
28 28/01/2009 03/06/2009 FALSE
29 04/02/2009 03/06/2009 FALSE
30 11/02/2009 09/06/2009 FALSE
31 18/02/2009 09/06/2009 FALSE
32 25/02/2009 09/06/2009 FALSE
33 04/03/2009 09/06/2009 FALSE
34 23/03/2009 09/06/2009 FALSE
35 06/09/2009 TRUE
Any ideas? as I cant see why or even how this is happening with all the settings as they are, stumped.
I have a form that selects a customer, gives a code and then inputs the details into two tables.
The problem table "LabDespatch" has these fields "[TransID], [DespatchDate], [DateCreated], [CurrentDespatch]" and a linked subtable, linked on TransID that stores the details of the customers that will/have despatched on a particular date.
The current people being despatched to the lab are entered under the [CurrentDespatch] number (automatically via a form button). When the time comes to despatch the current people to the lab, a form button is pushed and the despatched date is updated in the master table and the linked details table.
Then the [CurrentDespatch] for that group is set to false and new group is created under the next group number. At this time the current date is saved to the field [DateCreated] and its [CurrentDespatch] is set to true.
This is done with the following code:
DespatchSql = " INSERT INTO LabDespatch ([TransId], [DateCreated], [CurrentDespatch]) " _
& " VALUES (" & DMax("TransId", "LabDespatch") + 1 & ", #" & CurrentDate & "#, " & True & ") "
CurrentDate is a date variable that is set to the following:
CurrentDate = Format(Date, "dd/mm/yyyy")
The problem is that the date that appears in the table is the wrong way around in the mm/dd/yyyy (like americanized, I am in Australia and want dd/mm/yyyy).
the current date 09/06/2009 appears as 06/09/2009 in the table. Yet the table is set to date/time (format is dd/mm/yyyy), as you can see (above) I format a variable to dd/mm/yyyy to insert in case the computers short date is set wrong.
I have used the # for date literal in the insert into sql statement and have verifed (by adding a watch on the variable and a stop)that the variable does indeed get the correct format 09/06/2009.
As far as I can see I have everything set to the format dd/mm/yyyy in both the forms vb code and the table (and verified that the variable does indeed contain it correctly as 09/06/2009 before its written to the table), yet every stinking time I despatch a group and new master group is created in the table, the [DateCreated] field is always saved wrong i.e. 06/09/2009 (being the 6th of sept 09)
The table is formated right as I can manually input the date correctly, but when its done via code with the insert sql statement its wrong.
The following is an excel export showing how they have been saved, 27-34 have been manually changed in the table the last, 35 shows the sql save and wrongful format:
[TransId][DespatchDate][Datecreated] [CurrentDespatch]
27 21/01/2009 29/05/2009 FALSE
28 28/01/2009 03/06/2009 FALSE
29 04/02/2009 03/06/2009 FALSE
30 11/02/2009 09/06/2009 FALSE
31 18/02/2009 09/06/2009 FALSE
32 25/02/2009 09/06/2009 FALSE
33 04/03/2009 09/06/2009 FALSE
34 23/03/2009 09/06/2009 FALSE
35 06/09/2009 TRUE
Any ideas? as I cant see why or even how this is happening with all the settings as they are, stumped.