I'm getting the following error message:
Run-time error '2501':
The OpenForm action was canceled.
When I clicked debug, following is the line that is highlighted:
DoCmd.OpenForm "x5pouseaprtprvw", , , "po_code = '" & pcode & "' and bp_key = '" & pkey & "' and type = '" & ptype & "'"
Since pkey is an integer (in the table), I changed the syntax to:
DoCmd.OpenForm "x5pouseaprtprvw", , , "po_code = '" & pcode & "' and bp_key = " & pkey & " and type = '" & ptype & "'"
but got the following error:
Run-time erro '3075':
Syntax error (missing operator) in query expression 'po_code = '0002' and bp_key = and type = 'Local''.
If I take out the single quotes, it can't find pkey...what should I do?
Check to see whether there is a value contained in pkey before running the openform procedure. For that matter it might be wise to check that all of the values contain valid data. There's no point in opening the form if there isn't any match for all the criterea.