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

Code Help

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
I use the following code to automatically schedule a group of people.

Code:
   DoCmd.RunSQL "INSERT INTO tblShiftDetail " & "(EmployeeNumber,ShiftNumber,ShiftDetailDate,numberofhours ) VALUES " & "('" & vEmployee & "', '" & vShift & "', '" & vDate & "', '" & vDate & "');"
        vShift = 1
        vcount = 1
            Do While vcount <= 16 ' need # of employees for this shift
                vEmployee = vEmployee + 1
                If vEmployee > 27 Then ' change to however many employees you have
                    vEmployee = 1
                End If
                ' store employee and shift and date in detail new record
        DoCmd.RunSQL "INSERT INTO tblShiftDetail " & "(EmployeeNumber,ShiftNumber,ShiftDetailDate ) VALUES " & "('" & vEmployee & "', '" & vShift & "', '" & vDate & "');"
                vcount = vcount + 1
            Loop

I am attempting to change the following line of code so that when i want to change the number of people that are scheduled for a particular shift number that it will pull data from either a table or a field on a form instead of having to go into the code and change it there:

Code:
     Do While vcount <= 16 ' need # of employees for this shift

I thought this would be simple but i cannot get it to run properly, i am not getting any errors but my schedule is not being produced properly. I have tried something like this:

Code:
     Do While vcount <= DLookUp("[need]","tblshiftneed","shiftnumber =  '1'") ' need # of employees for this shift

and

Code:
Do While vcount <= forms!frmtestpulldata!m1 ' need # of employees for this shift

Again, I am not getting any errors but I am not getting the desired results. I am not sure if anyone can help me with the information I have given here but if you can, I would sincerely appreciate it.

Thanks for any help or suggestions.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top