Microsoft Access can't find my macro?

K

Kate

Module 1 conatins 2 subs

Option Compare Database

Sub SingleAvailability()

End Sub

Sub CreateBooking()

End Sub

I then have a macro connected to a form:

Option Compare Database

Private Sub Command13_Click()
On Error GoTo Err_Command13_Click

DoCmd.OpenQuery "CreateBooking"

Exit_Command13_Click:
Exit Sub

Err_Command13_Click:
MsgBox Err.Description
Resume Exit_Command13_Click

End Sub

When I click the button I get the error message Microsoft
Access can't find the Object 'CreateBookin.'

What is likely to be the problem?
 
G

George Nicholson

<DoCmd.OpenQuery "CreateBooking"> tells Access to look for a query named
CreateBooking, not a Subroutine/Procedure called CreateBooking. Unless the
db also had a query named CreateBooking, that line is guaranteed to fail.

If you want your command button to run your subroutine, try replacing the
line above with:

Call CreateBooking
or simply
CreateBooking
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top