Help with VBA - Runtime error (1 Viewer)

K1Kingy

Registered User.
Local time
Today, 15:26
Joined
Jun 12, 2008
Messages
20
Ok i'm not sure if this is complex or not (I hope not). In MS access 2007, I am creating a library database system, with members forms, book forms and issue forms.

When adding a book into the book table There is a check box called 'onShelf' which speaks for itself, if it is checked it is on the shelf, if not... then it isn't.

Now when this box is uncheck it won't be avaliable in the list of books that are able to be issued. (with me so far.. hope so).

Ok now when i issue a book i have another check box called 'Issued'. When this is checked it means the book is issued. When i check this box what i want the VBA code to do is uncheck the 'onShelf' checkbox making the book unavaliable in the list.

So the vba code i really need help with is

Code:
Private Sub issued_AfterUpdate()
   Dim SQLUpdate As String
   SQLUpdate = "UPDATE tbl.book SET onShelf=false WHERE bookID=_BOOKIDHERE_;"
   DoCmd.RunSQL SQLUpdate
End Sub

When i run this code i get the error

Run-Time error '3024':

Could not find path\to\documents\tbl.mdb


Any help would be great. Thanks
 

Guus2005

AWF VIP
Local time
Today, 05:26
Joined
Jun 26, 2007
Messages
2,642
Your _BOOKIDHERE_ is incorrect. Try this:
Code:
SQLUpdate = "UPDATE tbl.book SET onShelf=false WHERE bookID= " & _BOOKIDHERE_ & ";"
HTH:D
 

K1Kingy

Registered User.
Local time
Today, 15:26
Joined
Jun 12, 2008
Messages
20
Ok that does help. I just put _BOOKIDHERE_ just to make the query look proper. But i didn't know about any of the & symbols. So thanks, I managed to fix the error as well.
 

Users who are viewing this thread

Top Bottom