Error Message

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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'"
 
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]
 
Back
Top