Attn Graham Seach - Runtime error 2501

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
 
G

Graham R Seach

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
 

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