Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Location
    Philippines
    Posts
    3

    Unanswered: OpenForm action canceled: what to do?

    Hi all,

    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?

    thanks!

  2. #2
    Join Date
    Nov 2003
    Location
    Netherlands
    Posts
    85

    Re: OpenForm action canceled: what to do?

    Originally posted by redge_r
    Hi all,

    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?

    thanks!
    Didn't you forget " after pkey?

    DoCmd.OpenForm "x5pouseaprtprvw", , , "po_code = '" & pcode & "' and bp_key = '" & pkey & "'" and type = '" & ptype & "'"

    or leave all single quotes out only leave them at the last
    DoCmd.OpenForm "x5pouseaprtprvw", , , "po_code = " & pcode & " and bp_key = " & pkey & " and type = '" & ptype & "'"


    I'm not sure. I always do trial and error.

  3. #3
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Smile Re: OpenForm action canceled: what to do?

    Originally posted by redge_r
    Hi all,

    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?

    thanks!
    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.

    Gregg

  4. #4
    Join Date
    Dec 2003
    Location
    Philippines
    Posts
    3

    thanks for the help!

    Thanks to everyone who replied. I inserted the following code before DoCmd to ensure that bp_key always has a value:

    If IsNull(Me!bp_key) Then
    pkey = 0
    Else
    pkey = Me!bp_key
    End If

    It now works!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •