468,315 Members | 1,408 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,315 developers. It's quick & easy.

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.
Nov 12 '05 #1
2 6684
st**********@easthants.gov.uk (Stuart Clark) wrote in
news:55*************************@posting.google.co m:
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.

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

Nov 12 '05 #2
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.
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Smriti Dev | last post: by
1 post views Thread by Smriti Dev | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.