jlathem
Technical User
- Jul 25, 2010
- 27
Hey Guys,
I am still very new to VBA and hope someone here can help me out.
I am getting an Application-defined or object-defined error” running the SQL below.
I am trying to Update a table field call CD_Closed (Y/N Boolean) when a control on the parent form called Amount_to_Disposition reached $0.00. Basically if Amount_to_Disposition = 0 ($0.00) then run the SQL Update and Set CR_Closed to 1, Yes, or True… whatever works but I have tried all 3 of them and I can’t seem to be able to get anything to actually work for me.
I get up to the SQL before it stops. I think it may be in the SET argument as the CR_Closed is a Y/N field but the code gives me the same error if I use 1, Yes, or True.
As always, thanks for your help.
James
I am still very new to VBA and hope someone here can help me out.
I am getting an Application-defined or object-defined error” running the SQL below.
I am trying to Update a table field call CD_Closed (Y/N Boolean) when a control on the parent form called Amount_to_Disposition reached $0.00. Basically if Amount_to_Disposition = 0 ($0.00) then run the SQL Update and Set CR_Closed to 1, Yes, or True… whatever works but I have tried all 3 of them and I can’t seem to be able to get anything to actually work for me.
I get up to the SQL before it stops. I think it may be in the SET argument as the CR_Closed is a Y/N field but the code gives me the same error if I use 1, Yes, or True.
As always, thanks for your help.
James
Code:
Private Sub Add_A_Disposition_Exit(Cancel As Integer)
'Update the status of the parent record
Dim strSQL As String
'If Amount_to_Disposition is 0 then close the record
If Me.Parent.Amount_to_Disposition < 0.01 Then
'MsgBox is for testing only
MsgBox "You are in the IF argument"
[highlight]
strSQL = "UPDATE Cash_Record " & _
"SET Cash_Record.CR_Closed = 1" & _ ‘Cash_Record.CR_Closed is a Y/N field
" WHERE Cash_Record.CR_CNN = " & Me.Parent.CR_CNN ‘CR_CCN is a Double
[/highlight]
'MsgBox is for testing only
MsgBox "You are past the SQL defination"
'DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
'DoCmd.SetWarnings True
'MsgBox is for testing only
MsgBox "the query ran"
End If
End Sub