Novice having problems executing a macro - Help

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?
 
D

Douglas J. Steele

CreateBooking is a subroutine, not a query. OpenQuery is only used with
Queries.

Try replacing

DoCmd.OpenQuery "CreateBooking"

with

Call CreateBooking
 
T

tina

you listed two public procedures, but your private sub says to open a
*query*. do you have a query named "CreateBooking" in the database? if yes,
is the spelling/spacing of the object name in the database window *exactly*
the same as the spelling/spacing you use in the VBA code?
 

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

Top