DaveyEdgar
Technical User
I have a query based on two tables with a one to many relationship.
Employees Table
recordid (one side)
Attendance Table
recordid (many side)
type
from
to
returndate
daycount
Attendance query - has all the above fields.
and a form...
Form field/controls (data source is not based on attendance query; the form is based on a different query)
cboType
From
To
returndate
daycount
recordid
I have a button that when clicked will take the data entered into the Form field/controls listed above and enter it into the Attendance query as a new record into the respective fields.
My code...
The code doesn't work. Can anyone tell me what I did wrong?
Employees Table
recordid (one side)
Attendance Table
recordid (many side)
type
from
to
returndate
daycount
Attendance query - has all the above fields.
and a form...
Form field/controls (data source is not based on attendance query; the form is based on a different query)
cboType
From
To
returndate
daycount
recordid
I have a button that when clicked will take the data entered into the Form field/controls listed above and enter it into the Attendance query as a new record into the respective fields.
My code...
Code:
Private Sub cmdaddatt_Click()
DoCmd.RunSQL "INSERT INTO [qryattendance](type,from,to,returndate,daycount,recordid)VALUES (" & "'" & Me![cbotype] & "'," & "#" & Format(Me![from], "yyyy-mm-dd") & "#," & "#" & Format(Me![to], "yyyy-mm-dd") & "#," & "#" & Format(Me![returndate], "yyyy-mm-dd") & "#," & Me![daycount] & "'," & Me![recordid] & " ',)"
End Sub
The code doesn't work. Can anyone tell me what I did wrong?