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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Precedure Help??????? 1

Status
Not open for further replies.

quest4

Technical User
Aug 27, 2001
735
US
I need a liitle help on the wording. I have a text box in a form, in the properties sheet under Before Update, I would like to make a small procedure which says:
If X=1 or If X=2 Then
Enter data in the text field
Else Go Previous tab.

Can Someone please let me know the extact expression or wording. Thanks alot in advance to anyone responding.
 
What does x refer to?

Could u just elaborate a little please?

What do you mean by Enter data in text field? Does that mean if 'x' = 1 or 2 then allow the value entered in the text box, and if 'X' doesn't equal 1 or 2 then delete whatever the user has entered into the text box?

Cheers,

Nick
 
Thanks for the response. Basically, all I am trying to do is prevent the accidental issuence of extra vacation weeks that aren't earned. I have a field, actually called NumberVacationm Weeks, which has a value of 0-4. I have four text boxes to enter up to four vacation weeks. I did put this little code in validation rules, but it krept getting locked in loops:
(NumberVacationWeeks=2 Or
NumberVacationWeeks=3 Or
NumberVacationWeeks=4)

So I figured I would try this in Before Update, so I could tell it that if not one of these, go to last or previous tab. That way I wouldn't get in any more loops. Thanks again for the response.
 
Another quick Q before we start.

A record is on the form. The NumberVacationWeeks (for example) has 2 in it. Does this then mean that only the first 2 text boxes can have data input into them.

Or do u mean you only want the user to be able to key in 0,1,2,3 or 4 in the 1st text box?

Cheers,

Nick
 
You got it right with the two text boxes. Thanks again.

PS I have been use 1, if it matters, it is quicker.
 
Cheers.

Try this. I am going to make some assumtions. Just modify this to reflect the actual names of text boxes etc.

Text box with 1,2,3 or 4 in I will call txtHolidayWeeks. The others i will call or easiness text1, text2, text3 + text4.
I have not Acc in front of me so i may make some typos.

private sub txtHolidayWeeks_Afterupdate()

select case txtholidayWeeks

case 0
text1=null
text1.enabled=false
text2=null
text2.enabled=false
text3=null
text3.enabled=false
text4=null
text4.enabled=false

case 1
text1.enabled=true
text2=null
text2.enabled=false
text3=null
text3.enabled=false
text4=null
text4.enabled=false

case 2
text1.enabled=true
text2.enabled=true
text3=null
text3.enabled=false
text4=null
text4.enabled=false

etc etc etc

end select

Hope this is helps. If not, I am here for a while yet.

Cheers,

Nick



end sub
 
I didn't think that it would be so extensive as to us case. I thought it would be a little If -> Then -> Else type for each of the VacationWeek1-4 text boxes. The little expression previously mentioned worked, except that if you tryed and put in a date, into the second text box and you had a one in NumberVacation Weeks, you could not get out unless you click the X and it would not save the record. Basically, If (NumberVacationWeeks=2 Or
NumberVacationWeeks=3 Or
NumberVacationWeeks=4) Then let me enter a date in the text box Else send me to previous box or tab. Well it is 5:30 here time for the weekend, I have been at this way to long and have racked my mind way to much on trying to figure this out. Thanks again for all the help.
 
Here is an easier solution.

text1_afterUpdate()

if txtHolidays = 0 then
text1=null
exit sub
end if

end sub

text2_afterUpdate()

if txtHolidays = 1 then
text2=null
exit sub
end if

end sub

text2_afterUpdate()

if txtHolidays = 2 then
text3=null
exit sub
end if

end sub

Nick
 
Here is an easier solution.

text1_afterUpdate()

if txtHolidays = 0 then
text1=null
exit sub
end if

end sub

text2_afterUpdate()

if txtHolidays = 1 then
text2=null
exit sub
end if

end sub

text3_afterUpdate()

if txtHolidays = 2 then
text3=null
exit sub
end if

end sub

Nick
 
I did the second ffrom the bottom and it kind of worked. I used NumberVactionWeeks = 1 and I could enter a date in DateVacation1, then I tabed to DateVacation2 and entered a date and tabed to DateVacation3 and DateVacation2 went blank, that wass great. Then just for grins, I tryed entering a date inDateVacation3 and tab to DateVacation4 The date stayed. So I tryed altering the precedure to this:

Private Sub DateVacation2_AfterUpdate()
If NumberVacationWeeks = 1 Then
DateVacation2 = Null
DateVacation3 = Null
DateVacation4 = Null
End If
End Sub

I got the same results, dates in DateVacation3 and DateVacation4. It didn't like it when I tried to add And to the statement not did it like "," either. What did I do wrong? Thank you for the response it was a help.
 
Tried using the last method and I still get the same results. Thansk for any help.
 
I managed to modify it and now it is working. Thanks a lot for everything. FYI in the procedure with case, I get errors on the .Enabled's, something about \a wrong use. Thansk again.
 
Just got online. Glad most of it is working. What is the exact error you get with the enabled?
 
I don't really think I want to change anything, nor that it is working OK. But I did try the CASE style, before I got this working and it would eror out on the secnd line of Case0 and it would high lite the .Enabled and it said something about mis-use of variable or something. I am start to under stand a little of this stuff, isn't that scary. On last qquestion, do you know any thing about select queries? If so and you would like a challenge I have a query titled "Need Help with a Condition in a selct Query". Thanks alot for all of the help you gave me on this one, like I said, it is working now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top