Attn Graham Seach - Runtime error 2501

  • Thread starter Thread starter Lurch
  • Start date Start date
L

Lurch

Hi Graham;

Thank you for replying to my question regarding "Opening a form based upon
two fields".

You were right about the fields being strings. I tried your example but now
I get a Run-time error 2501 Open form was cancelled...

What could be causing this?

Thanks
 
Firstly, next time, rather than starting a new thread, please continue using
the existing one.

Try using the Nz() function:

DoCmd.OpenForm "frm_Form2", , , "Nz([field1], '') = """ & _
Nz(Forms!Form1!Field1, '') & """ And Nz([field2], '') = """ & _
Nz(Forms!Form1!Field2, '') & """"

I don't think nulls are the problem, but I want to rule them out. If this
doesn't resolve the issue, you must have some code in the form's Open event
that sets Cancel = True. If that's the case, you need to place "On Error
Resume Next" just before the DoCmd.OpenForm line.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Back
Top