P
ppullag1
Guest
Hello Everybody.....
I am trying to get parts of the date from combo boxes in a form in Access, combine them to form a date and insert it into a table. I am having trouble forming the date and inserting the date field into the table. The following is the code I am using:
Dim strSQL As String
Dim d As Date
Dim a, b, c, e As String
Dim day, mon, yr As Integer
day = [Forms]![Enter Participation Count]![DayCombo]
mon = [Forms]![Enter Participation Count]![MonthCombo]
yr = [Forms]![Enter Participation Count]![YearCombo]
a = CInt(mon)
b = CInt(day)
c = CInt(yr)
d = DateSerial(a, b, c)
strSQL = "INSERT INTO transfercount(Area, Program, Count, Date) VALUES([Forms]![Enter Participation Count]![Area], [Forms]![Enter Participation Count]![Program],[Forms]![Enter Participation Count]![Count], " & d & ") "
While debugging, I can see that a, b, c are getting correct values from the form in the Integer format. But when I assign the d to DateSerial(a,b,c), its not getting the correct date (Its getting some other date). I don't know whats wrog here.
After that, the query works fine but it does not insert the that wrong date value in d, instead it inserts some time value like 12.00.25AM.....
Any help in this regard is appreciated.
Thanks,
Redd
I am trying to get parts of the date from combo boxes in a form in Access, combine them to form a date and insert it into a table. I am having trouble forming the date and inserting the date field into the table. The following is the code I am using:
Dim strSQL As String
Dim d As Date
Dim a, b, c, e As String
Dim day, mon, yr As Integer
day = [Forms]![Enter Participation Count]![DayCombo]
mon = [Forms]![Enter Participation Count]![MonthCombo]
yr = [Forms]![Enter Participation Count]![YearCombo]
a = CInt(mon)
b = CInt(day)
c = CInt(yr)
d = DateSerial(a, b, c)
strSQL = "INSERT INTO transfercount(Area, Program, Count, Date) VALUES([Forms]![Enter Participation Count]![Area], [Forms]![Enter Participation Count]![Program],[Forms]![Enter Participation Count]![Count], " & d & ") "
While debugging, I can see that a, b, c are getting correct values from the form in the Integer format. But when I assign the d to DateSerial(a,b,c), its not getting the correct date (Its getting some other date). I don't know whats wrog here.
After that, the query works fine but it does not insert the that wrong date value in d, instead it inserts some time value like 12.00.25AM.....
Any help in this regard is appreciated.
Thanks,
Redd