I am new to this site. This is my first post. The entire function is listed below. I need to use a variable name for 'rstGen![fDay1]' in the line
If rstGen![fDay1] = -1 Then ' if yes
There are 7 fDate fields, fDate1 thru fDate7. I need to cycle through each one. Please help!
If rstGen![fDay1] = -1 Then ' if yes
There are 7 fDate fields, fDate1 thru fDate7. I need to cycle through each one. Please help!
Code:
Function completeSchedule() ' get each record from mtGeneric and put in tblSchedule for the full week
Dim x As Long
Dim db As Database
Dim rstSch As Recordset
Dim rstGen As Recordset
Dim dateDate As Date
Set db = DBEngine(0)(0)
Set rstSch = db.OpenRecordset("tblSchedule", dbOpenDynaset)
Set rstGen = db.OpenRecordset("mtGeneric2", dbOpenDynaset)
strField = "fDate1"
dateDate = [fDateMondays] ' date to start
' While Not rstGen.EOF ' records in mtGeneric2
For x = 1 To 7 ' days in week
rstSch.FindFirst "[fDate] = #" & dateDate & "# "
If Not rstSch.NoMatch Then '
' there are 7 fDay fields in table mtGeneric2 fDay1 thru fDay7. _
I need to cycle through each one
If rstGen![fDay1] = -1 Then ' if yes
rstSch.Edit
rstSch![fTxtWorkName] = Nz(rstGen![fTxtWorkName])
rstSch![fTxtCrew] = Nz(rstGen![fTxtCrew])
rstSch![fTxtTask] = Nz(rstGen![fTxtTask])
rstSch![fTxtShift] = Nz(rstGen![fTxtShift])
rstSch![fTxtDrives] = Nz(rstGen![fDrives])
rstSch.Update
End If
End If
Next x
rstGen.MoveNext
dateDate = dateDate + x
' Wend
Me.Refresh
End Function
Last edited by a moderator: