G
Guest
I have a box in a form getting its information from a query. When I try to
select a record in the box, I always get the first record in the box.
Private Sub Arrived_Click()
Dim varitm As Variant
Dim db As Database
Dim rs1 As Recordset
Dim PersonID As Integer
Dim JobID As Integer
Dim first As String
Dim Last As String
Dim sql1 As String
Dim OTJ As Boolean
Dim Active_Jobs As String
Dim Current As Date
Dim ok As Integer
Active_Jobs = "jobs_active"
Set db = CurrentDb
Current = Now()
ok = 0
MsgBox Me.ListCurrent.ItemData(varitm)
MsgBox varitm
If IsNull(Me.ListCurrent.ItemData(varitm)) = False Then
PersonID = Me.ListCurrent.ItemData(varitm)
sql1 = " SELECT " & Active_Jobs & ".* " _
& " FROM " & Active_Jobs & " " _
& " WHERE " & Active_Jobs & ".PersonID = " & PersonID & " ;"
Set rs1 = db.OpenRecordset(sql1, dbOpenDynaset) 'active jobs
If Not rs1.BOF And Not rs1.EOF Then
rs1.Edit
Last = rs1!LastName
ok = MsgBox("Has " & Last & " arrived on the job?",
vbYesNo)
If ok = 6 Then
rs1!TravelTime = Current
rs1!OTJ = "True"
rs1.update
End If ' ok
rs1.close
End If 'eof bof
End If 'isnull
Me.ListCurrent.Requery
End Sub
select a record in the box, I always get the first record in the box.
Private Sub Arrived_Click()
Dim varitm As Variant
Dim db As Database
Dim rs1 As Recordset
Dim PersonID As Integer
Dim JobID As Integer
Dim first As String
Dim Last As String
Dim sql1 As String
Dim OTJ As Boolean
Dim Active_Jobs As String
Dim Current As Date
Dim ok As Integer
Active_Jobs = "jobs_active"
Set db = CurrentDb
Current = Now()
ok = 0
MsgBox Me.ListCurrent.ItemData(varitm)
MsgBox varitm
If IsNull(Me.ListCurrent.ItemData(varitm)) = False Then
PersonID = Me.ListCurrent.ItemData(varitm)
sql1 = " SELECT " & Active_Jobs & ".* " _
& " FROM " & Active_Jobs & " " _
& " WHERE " & Active_Jobs & ".PersonID = " & PersonID & " ;"
Set rs1 = db.OpenRecordset(sql1, dbOpenDynaset) 'active jobs
If Not rs1.BOF And Not rs1.EOF Then
rs1.Edit
Last = rs1!LastName
ok = MsgBox("Has " & Last & " arrived on the job?",
vbYesNo)
If ok = 6 Then
rs1!TravelTime = Current
rs1!OTJ = "True"
rs1.update
End If ' ok
rs1.close
End If 'eof bof
End If 'isnull
Me.ListCurrent.Requery
End Sub