G
GoBrowns!
Hi;
I am trying to create a "submit" button that will append the form fields to
a table. The user will click "submit", get a message box to make sure they
REALLY want to submit, then if they click yes the data will be submitted.
I am getting syntax errors in my code, and I can't figure out what is wrong.
I wrote the code two different ways.....
Here it is.....
This part seems to work....
Private Sub cmdSubmit_Click()
'Asks user one more time if they are sure they want to submit,
'then appends form data to table and clears form.
Dim strLastChance As String
Dim strAppend As String
Dim strSQL As String
strLastChance = MsgBox( _
Prompt:="Are you sure you want to submit record?", _
Buttons:=vbYesNo + vbExclamation, _
Title:="Confirm Submission Decision")
If vbYes Then
Here is Option #1 for after my "if" line...
strSQL = "INSERT INTO tblAttendanceRecords(EmployeeID, EmployeeName, Date," _
VacationTimeUsed, SickTimeUsed, ProperDocumentationFiled, Tardy,
TardyTime, MissedPunch, _
Occurrence, OccurrenceDescription, OccurrenceValue,
NonOccurrenceDescription, _
AdditionalComments)VALUES("&me.txtEmployeeID&","&me.cboEmployeeName&", _
"&me.datDate&","&me.intVacationUsed&","&me.intSickUsed&", _
"&me.ckProperDoc&","&me.ckTardy&","&me.cboTimeTardy&", _
"&me.ckMissedPunch&","&me.ckOccurrence&, _
"&me.cboTypeOccurrence&","&me.txtOccurrenceValue&", _
"&me.cboNonOccurrence&","&me.txtAdditionalComments&")";
DBEngine(0)(0).Execute strSQL
And Option #2.....
strAppend = "INSERT INTO tblAttendanceRecords(txtEmployeeID as
EmployeeID," _
cboEmployeeName as EmployeeName, _
datDate as Date, _
intVacationUsed as VacationTimeUsed, _
intSickUsed as SickTimeUsed, _
ckProperDoc as ProperDocumentationFiled, _
ckTardy as Tardy, _
cboTimeTardy as TardyTime, _
ckMissedPunch as MissedPunch, _
ckOccurrence as OccurrenceDescription, _
cboTypeOccurrence as Occurrence, _
txtOccurrenceValue as OccurrenceValue, _
cboNonOccurrence as NonOccurrenceDescription, _
txtAdditionalComments as AdditionalComments)";
DoCmd.RunSQL strAppend
Will either of these options work??? If so, how do I fix one of them to
append the info???
So stumped... thanks for the help!!!!!!!
I am trying to create a "submit" button that will append the form fields to
a table. The user will click "submit", get a message box to make sure they
REALLY want to submit, then if they click yes the data will be submitted.
I am getting syntax errors in my code, and I can't figure out what is wrong.
I wrote the code two different ways.....
Here it is.....
This part seems to work....
Private Sub cmdSubmit_Click()
'Asks user one more time if they are sure they want to submit,
'then appends form data to table and clears form.
Dim strLastChance As String
Dim strAppend As String
Dim strSQL As String
strLastChance = MsgBox( _
Prompt:="Are you sure you want to submit record?", _
Buttons:=vbYesNo + vbExclamation, _
Title:="Confirm Submission Decision")
If vbYes Then
Here is Option #1 for after my "if" line...
strSQL = "INSERT INTO tblAttendanceRecords(EmployeeID, EmployeeName, Date," _
VacationTimeUsed, SickTimeUsed, ProperDocumentationFiled, Tardy,
TardyTime, MissedPunch, _
Occurrence, OccurrenceDescription, OccurrenceValue,
NonOccurrenceDescription, _
AdditionalComments)VALUES("&me.txtEmployeeID&","&me.cboEmployeeName&", _
"&me.datDate&","&me.intVacationUsed&","&me.intSickUsed&", _
"&me.ckProperDoc&","&me.ckTardy&","&me.cboTimeTardy&", _
"&me.ckMissedPunch&","&me.ckOccurrence&, _
"&me.cboTypeOccurrence&","&me.txtOccurrenceValue&", _
"&me.cboNonOccurrence&","&me.txtAdditionalComments&")";
DBEngine(0)(0).Execute strSQL
And Option #2.....
strAppend = "INSERT INTO tblAttendanceRecords(txtEmployeeID as
EmployeeID," _
cboEmployeeName as EmployeeName, _
datDate as Date, _
intVacationUsed as VacationTimeUsed, _
intSickUsed as SickTimeUsed, _
ckProperDoc as ProperDocumentationFiled, _
ckTardy as Tardy, _
cboTimeTardy as TardyTime, _
ckMissedPunch as MissedPunch, _
ckOccurrence as OccurrenceDescription, _
cboTypeOccurrence as Occurrence, _
txtOccurrenceValue as OccurrenceValue, _
cboNonOccurrence as NonOccurrenceDescription, _
txtAdditionalComments as AdditionalComments)";
DoCmd.RunSQL strAppend
Will either of these options work??? If so, how do I fix one of them to
append the info???
So stumped... thanks for the help!!!!!!!