G
gmazza via AccessMonster.com
Hi there,
I need some help so I don't have to repeat my code a ton of times.
I have 20 Visit buttons on my form labelled Visit 1, Visit 2, etc. When the
user chooses a visit, the number gets stored in a text box. So they choose
Visit 2, the number 2 gets stored in a textbox.
Once they click any visit button, a Visit form opens and On Open I am doing
the following:
I am setting the declared integer VisitNo = to the text box, so 2 in this
case.
I have 20 VisitFlags, declared as integers, named VisitFlag1, VisitFlag2, etc.
I have a control form where the user decides which visits they want certain
info showing on the actual Visit form by clicking a check box for which visit
they want.
I open a recordset of the control form to see which visit the user chose.
In my recordset I do something like this:
If fld.Name = "Visit2" Then
If fld.Value = False Then
VisitFlag2 = 0
Else
VisitFlag2 = 2
End If
End If
So then, from the If statement above, I will be able to see if VisitFlag2 = 0,
meaning it wasn't chosen in the control form, or it equals 2, meaning it was
chosen.
So now I need to see if the VisitNo, which is at 2 because they clicked the
Visit 2 button, equals the Visit2Flag but I can't just use the word
Visit2Flag because there are 20 Flags, I just want to say something like:
If VisitNo = VisitFlag & VisitNo Then
blah blah
meaning:
If 2 = (the value of VisitFlag2)
Hope this makes sense!
Thanks for everyones help!
I need some help so I don't have to repeat my code a ton of times.
I have 20 Visit buttons on my form labelled Visit 1, Visit 2, etc. When the
user chooses a visit, the number gets stored in a text box. So they choose
Visit 2, the number 2 gets stored in a textbox.
Once they click any visit button, a Visit form opens and On Open I am doing
the following:
I am setting the declared integer VisitNo = to the text box, so 2 in this
case.
I have 20 VisitFlags, declared as integers, named VisitFlag1, VisitFlag2, etc.
I have a control form where the user decides which visits they want certain
info showing on the actual Visit form by clicking a check box for which visit
they want.
I open a recordset of the control form to see which visit the user chose.
In my recordset I do something like this:
If fld.Name = "Visit2" Then
If fld.Value = False Then
VisitFlag2 = 0
Else
VisitFlag2 = 2
End If
End If
So then, from the If statement above, I will be able to see if VisitFlag2 = 0,
meaning it wasn't chosen in the control form, or it equals 2, meaning it was
chosen.
So now I need to see if the VisitNo, which is at 2 because they clicked the
Visit 2 button, equals the Visit2Flag but I can't just use the word
Visit2Flag because there are 20 Flags, I just want to say something like:
If VisitNo = VisitFlag & VisitNo Then
blah blah
meaning:
If 2 = (the value of VisitFlag2)
Hope this makes sense!
Thanks for everyones help!