G
Guest
Hello all,
I am trying to write a receipt number that is in a subform to a different
table. Problem is that if I reference the Form.subform.field.... it doesn't
work if there are muiltiple records in the subform.. so I'm trying to capture
the receipt number as a variable and then throw the variable in my SQL. I'm
getting an OVERFLOW error.
Here is my whole code... Any thoughts would be greatly appreciated.
'** CODE Start
On Error GoTo cmd_Cancel_Click_Error
Dim tempReceipt_Number As Integer
'Purpose-To record Receipt numbers that are canceled. This will show a
continuous
'count of receipt numbers in the Donations table. The word CANCELED will
appear in the notes field
Dim SQL As String
DoCmd.SetWarnings False
tempReceipt_Number = Me.Receipt_Number
'This captures correct number
SQL = "INSERT INTO Donations ([Receipt Number], Notes, LastUserID ) " & _
"SELECT " & [tempReceipt_Number] & "AS [Receipt Number], " & _
"'Canceled' AS [Notes], " & _
"[Forms]![Opening]![EmployeeNum] AS [LastUserID];"
DoCmd.RunSQL SQL
MsgBox "Insert Complete for receipt " & Me.Receipt_Number
'This displays correct number
SQL = ""
'*** CODE CONTINUES for other things
Thanks again,
I am trying to write a receipt number that is in a subform to a different
table. Problem is that if I reference the Form.subform.field.... it doesn't
work if there are muiltiple records in the subform.. so I'm trying to capture
the receipt number as a variable and then throw the variable in my SQL. I'm
getting an OVERFLOW error.
Here is my whole code... Any thoughts would be greatly appreciated.
'** CODE Start
On Error GoTo cmd_Cancel_Click_Error
Dim tempReceipt_Number As Integer
'Purpose-To record Receipt numbers that are canceled. This will show a
continuous
'count of receipt numbers in the Donations table. The word CANCELED will
appear in the notes field
Dim SQL As String
DoCmd.SetWarnings False
tempReceipt_Number = Me.Receipt_Number
'This captures correct number
SQL = "INSERT INTO Donations ([Receipt Number], Notes, LastUserID ) " & _
"SELECT " & [tempReceipt_Number] & "AS [Receipt Number], " & _
"'Canceled' AS [Notes], " & _
"[Forms]![Opening]![EmployeeNum] AS [LastUserID];"
DoCmd.RunSQL SQL
MsgBox "Insert Complete for receipt " & Me.Receipt_Number
'This displays correct number
SQL = ""
'*** CODE CONTINUES for other things
Thanks again,