Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am getting "Application-defined or object-defined error"

Status
Not open for further replies.

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

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
 
Not that it is your current issue, but booleans are -1, and 0 not 1 and 0.
 
ZmrAbdulla, I only put the comments into the code above for posting purpose so anyone reading the code would know what was going on. The actual code being used doesn’t have the comments in it.

But I do thank you for pointing it out. I didn’t think anything about putting the comments in at the end of the like.

James
 
MajP

Thanks for pointing that out. Dropping the “-“ minus sign is just a typo.

James
 
Heu Guys,

I got this one worked out. Thanks for your help!

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top