Error Message

M

Mike

Hi

I am trying to use a command button within a form (frmOpenBooking)to open
another form (frmBooking) so that a field in the form (frmBooking) is equal
to a value in the current form (frmOpenBooking). I used the simplified code

DoCmd.OpenForm "frmBooking", acNormal, , [BookingNumber] = 5795186

with the 'Where condition' part of the code selecting the desired value for
the field. On clicking the button the following error message appeared.

Microsoft Office Access can't find the field '|' referred to in your
expression.

I would be very grateful for any advice that will help solve the problem.
Many thanks in advance.
 
B

Brendan Reynolds

You appear to be missing some quotes ...

DoCmd.OpenForm "frmBooking", acNormal, , "[BookingNumber] = 5795186"

I'm assuming here that the field BookingNumber is a numeric data type. If it
is a text field, you would need ...

DoCmd.OpenForm "frmBooking", acNormal, , "[BookingNumber] = '5795186'"
 
A

Allen Browne

The WhereCondition needs quotes:
DoCmd.OpenForm "frmBooking", acNormal, , "[BookingNumber] = 5795186"

If BookingNumber is a Text type field (not a Number field), it needs extra
quotes:
DoCmd.OpenForm "frmBooking", acNormal, , "[BookingNumber] = ""5795186"""

If you want to concatenate the value of the BookingNumber from this form:
DoCmd.OpenForm "frmBooking", acNormal, , "[BookingNumber] = " &
Me.[BookingNumber]
 

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