1
1jet
Hi all, please have a quick look at my form below.
http://img515.imageshack.us/img515/8040/timesheetcommentswq8.jpg
Right now, I have an INSERT query inside a loop for Days 1 - 7 of Project 1
(will probably create another loops outside for Projects 2 - 5).
The INSERT query is currently output onto a MSGBOX and looks fine to me.
After being happy with the query, I've changed the MSGBOX to DoCmd.RunSQL and
when I execute this from Access, apparently I have an "INSERT INTO syntax
error."
My code is below can anyone find what's wrong?
Function vbaTestAppend()
Dim strSQL As String
Dim project_count As Integer
Dim day_count As Integer
Dim projectcbo As String
Dim datebox As String
Dim daybox As String
project_count = 1
day_count = 0
projectcbo = "Forms!frmEmployeeTimesheet!cboSelectProject" & project_count
Do
day_count = day_count + 1
datebox = "Forms!frmEmployeeTimesheet!txtDay" & day_count
daybox = "Forms!frmEmployeeTimesheet!txtProj" & project_count & "Day" &
day_count
strSQL = "INSERT INTO tblHours ( [Project ID], [Employee ID], Date, Hours
) VALUES " & projectcbo & ", Forms!frmEmployeeTimesheet!cboSelectName, " &
datebox & ", " & daybox & ";"
DoCmd.RunSQL strSQL
Loop Until day_count = 7
End Function
http://img515.imageshack.us/img515/8040/timesheetcommentswq8.jpg
Right now, I have an INSERT query inside a loop for Days 1 - 7 of Project 1
(will probably create another loops outside for Projects 2 - 5).
The INSERT query is currently output onto a MSGBOX and looks fine to me.
After being happy with the query, I've changed the MSGBOX to DoCmd.RunSQL and
when I execute this from Access, apparently I have an "INSERT INTO syntax
error."
My code is below can anyone find what's wrong?
Function vbaTestAppend()
Dim strSQL As String
Dim project_count As Integer
Dim day_count As Integer
Dim projectcbo As String
Dim datebox As String
Dim daybox As String
project_count = 1
day_count = 0
projectcbo = "Forms!frmEmployeeTimesheet!cboSelectProject" & project_count
Do
day_count = day_count + 1
datebox = "Forms!frmEmployeeTimesheet!txtDay" & day_count
daybox = "Forms!frmEmployeeTimesheet!txtProj" & project_count & "Day" &
day_count
strSQL = "INSERT INTO tblHours ( [Project ID], [Employee ID], Date, Hours
) VALUES " & projectcbo & ", Forms!frmEmployeeTimesheet!cboSelectName, " &
datebox & ", " & daybox & ";"
DoCmd.RunSQL strSQL
Loop Until day_count = 7
End Function