Error in BETWEEN Code for DoCmd.OpenForm

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stuart Clark

    Error in BETWEEN Code for DoCmd.OpenForm

    Hi,
    I have the following lines of code:
    stLinkCriteria = "[Acres] BETWEEN " & [SearchBox1] & " AND " &
    [SearchBox2]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Every time I try and run this I get the following error:
    Run-Time Error 2501
    The OpenForm action was cancelled.

    Can anyone tell me what I've done wrong? The code should enable the
    user to enter to numerical values into textboxes SearchBox1 and
    SearchBox2 and see all records where the Acre values are between those
    entered.

    Cheers!
    Stu.
  • Bob Quintal

    #2
    Re: Error in BETWEEN Code for DoCmd.OpenForm

    stuart_clark@ea sthants.gov.uk (Stuart Clark) wrote in
    news:5530356c.0 309090836.c8a54 ff@posting.goog le.com:
    [color=blue]
    > Hi,
    > I have the following lines of code:
    > stLinkCriteria = "[Acres] BETWEEN " & [SearchBox1] & " AND "
    > &
    > [SearchBox2]
    > DoCmd.OpenForm stDocName, , , stLinkCriteria
    >
    > Every time I try and run this I get the following error:
    > Run-Time Error 2501
    > The OpenForm action was cancelled.
    >
    > Can anyone tell me what I've done wrong? The code should
    > enable the user to enter to numerical values into textboxes
    > SearchBox1 and SearchBox2 and see all records where the Acre
    > values are between those entered.
    >
    > Cheers!
    > Stu.
    >[/color]
    The problem probably doesn't lie here, but somewhere in the form
    whose name is passed in the variable stDocName. There may be some
    code in that form that closes it if some criteria is not met.

    Bob Q



    Comment

    • Stuart Clark

      #3
      Re: Error in BETWEEN Code for DoCmd.OpenForm

      Hi!
      Thanks - I actually found the problem just after I posted the message
      but didn't have time to post an update. I hadn't realised that you had
      to set the field type in the table to numerical - rather dumb of me
      really!
      Thanks for the advice though!
      Stu.

      Comment

      Working...