Cant run my Insert statement in VBA, Please help me
Hello,
Can someone help me? I've been working on this for a while now and my original question is here: http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=60929
Basicaly I'm making a booking system and i needed some code that will insert a booking record for each night of stay. So date 1 is arrival date and date 2 is departure date. So the statement should insert 3 values into the table, only there's a syntax error with the sql statement, i think it's because I'm not refering to the boxes on my form properly but can't find how I should do it.
I've made the module with the following code:
Private Sub add_booking_Click()
Dim BookDate As Date
Dim LeaveDate As Date
BookDate = Forms!Form!date1
LeaveDate = Forms!Form!date2
Do While BookDate < LeaveDate
DoCmd.RunSQL "INSERT INTO booking VALUES (Forms!form!room_no.text, bookdate, Forms!form!cust_no.text"
BookDate = BookDate + 1
Loop
End Sub
All help is very much appriciated.
Emma
Hello,
Can someone help me? I've been working on this for a while now and my original question is here: http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=60929
Basicaly I'm making a booking system and i needed some code that will insert a booking record for each night of stay. So date 1 is arrival date and date 2 is departure date. So the statement should insert 3 values into the table, only there's a syntax error with the sql statement, i think it's because I'm not refering to the boxes on my form properly but can't find how I should do it.
I've made the module with the following code:
Private Sub add_booking_Click()
Dim BookDate As Date
Dim LeaveDate As Date
BookDate = Forms!Form!date1
LeaveDate = Forms!Form!date2
Do While BookDate < LeaveDate
DoCmd.RunSQL "INSERT INTO booking VALUES (Forms!form!room_no.text, bookdate, Forms!form!cust_no.text"
BookDate = BookDate + 1
Loop
End Sub
All help is very much appriciated.
Emma