Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Goto Next Record Problem 2

Status
Not open for further replies.

infinitx

Technical User
Feb 26, 2004
212
US
Hi,

I have a form that has a textbox in it that serves as a counter. When a certain number is shown in the counter, I want go to Next Record in another form that is open as a pop-up.

I am using the following code:

Code:
If Form_ICL41.Text2.Value = 3 Or 5 Or 7 Or 9 Or 11 Or 13 Or 15 Or 17 Or 19 Or 21 Or 23 Or 25 Or 27 Or 29 Or 31 Or 33 Or 35 Or 37 Or 39 Or 41 Or 43 Or 45 Or 47 Or 49 Or 51 Or 53 Or 55 Or 57 Then

    Dim stDocName As String

    stDocName = "Macro3"
    DoCmd.RunMacro stDocName
Else
Form_ICL4.Visible = True
End If


Macro 3: Goto Record

Object Type: Form
Object Name: ICL41
Record: Next

However, when the counter shows "2", it still goes on to the Next Record even though the code skips "2" in the If...Then Statement!

Why is it doing that?

Thanks!

----
Alex

Anytime things appear to be going better, you have overlooked something.
 
Your syntax is invalid:
If Form_ICL41.Text2.Value = 3 Or Form_ICL41.Text2.Value = 5 Or Form_ICL41.Text2.Value = 7 ... Then

You may consider this:
If Form_ICL41.Text2.Value > 2 And Form_ICL41.Text2.Value < 58 And (Form_ICL41.Text2.Value Mod 2) = 1 Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
change this:
If Form_ICL41.Text2.Value = 3 Or 5 Or 7 Or 9 Or 11 Or 13 Or 15 Or 17 Or 19 Or 21 Or 23 Or 25 Or 27 Or 29 Or 31 Or 33 Or 35 Or 37 Or 39 Or 41 Or 43 Or 45 Or 47 Or 49 Or 51 Or 53 Or 55 Or 57 Then

to this:
If Form_ICL41.Text2.Value = 3 OR
Form_ICL41.Text2.Value = 5 OR
Form_ICL41.Text2.Value = 7 OR etc

or this:
Select Case Form_ICL41.Text2
Case = 3, 5, 7, 9, 11, 13, etc
code here
Case Else
code here
End Select


Randy
 
PHV,

Thanks! That was exactly what I was looking for! One more question, how would I modify the code if I want to skip 10? For example, "11 or 21"?

randy700,

Thank you too! However, PHV's code is easier to enter and doesn't take up as much room. But thanks anyways!

----
Alex

Anytime things appear to be going better, you have overlooked something.
 
(Value Mod 10) <> 1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top