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!

Programming question re: defining a variable

Status
Not open for further replies.

Chris1977

Technical User
Feb 2, 2003
50
US
Hey folks,

I am not a programmer by trade so i'm hoping some of you will be able to give me a hand.

I have a text field called txtdaysworked. In this field the workers weekly schedule is as follows XMTWTFX and so on depending on what days they have off. Apart from this there is a series of 7 text boxes, each corresponding to the days of the week and the hours the employee worked for that week. So for example there is txtSunHours, txtMonHours etc.

What i want is for each instance of XMTWTFX the txtMonHours, txtTueHours, txtWedHours, txtThuHours, txtFriHours fields will fill with a value of 8 for hrs worked. Obviously if they worked SMTWTXX i'd want all fields except txtFriHours and txtSatHours to fill with a value of 8.

I'm sure there is an easy way to do this such as declaring a variable for the days worked box and on every instance of that variable filling the approporiate text boxes but not being a programmer that is something i am fairly new at. so if you guys can help me with the code and where to put it i'd really appreciate it.

thanks,
chris
 
This is fairly simple. Put this code in the Control Source of each of your test controls on your form for Sun, Mon, Tue, Wed, . . .Sat.
=IIf(Mid$([txtWklSchedule],1,1)="X",0,8)

The parameter that is in red should be incremented by 1 for each day of the week. (i.e. Sum - 1, Mon. - 2, Tues. - 3 . . .thru Sat - 7. Now you will also have to change the name of the WeeklySchedule control to the name of your control. That is in red also.

One more thing. This statement puts either a 0 or an 8 in the text box. If you don't want the 0 but a blank box then replace the 0 parameter with "".

Let me know if this works for you.

Bob Scriver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top