Tamang Aman
New member
- Local time
- Yesterday, 21:02
- Joined
- Dec 28, 2014
- Messages
- 7
Dear Experts
This is my first time ever in Forum and seeking of big help from all of you.
I am very very new to VBA and I have been self-learning VBA from two month and have been assigned to new project “Work Authorization & Lock Out Tag Out”
I have table called tblWA & tblLOTO
Basically most of the LOTO/s are associated with WA #, following example
WA # in tblWA
Associated LOTO/s in tblLOTOs
25258
123456
123457
123458
123459
25259
123410
123411
123412
123413
However, both tables are in relationship right now
Now, this is my goal to achieve
I have form called WA Switch Board where I have Datasheet View form with all WA records, fields are WA#, WAStatus, WAIssuedDate, IssuedBy, CompletionDate and etc but I have dropdown with with WAStatus with (In Field Today, On-Hold, In Approval, Cancelled, Close)
Now from the main switch board when authorized people try to change the status of permit to Closed I want recordset or count to loop through tblLOTO and give me a message box if associated LOTO/s status not equal to Close
In other word, if the associated LOTO/s are not close then the selected WA # in WA Switch Board can’t close
Here is the code I have been playing with no success
Private Sub PermitStatus_AfterUpdate()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * from qryLOTO where (WAAndPrefix)= " & Me.WAPrefix & " AND (LOTOStatusList) = "In Field Today, "On-Hold, "In Approval")
On Error Resume Next
DoCmd.SetWarnings False
''''''''''''''''''''''''''''''''
If rs.EOF Then
On Error Resume Next 'Exit Sub
DoCmd.SetWarnings False
If MsgBox("The selected LOTO " & WAPrefix.Value & " The WA # you trying close are associated with many LOTO/s, can't close this WA# unless associated LOTO/s are closed"),,"Warning !!! Please read carefully"
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub
I am looking forward to receive any help from any of you that will safe my life
Thanks & best regards,
Tamang
This is my first time ever in Forum and seeking of big help from all of you.
I am very very new to VBA and I have been self-learning VBA from two month and have been assigned to new project “Work Authorization & Lock Out Tag Out”
I have table called tblWA & tblLOTO
Basically most of the LOTO/s are associated with WA #, following example
WA # in tblWA
Associated LOTO/s in tblLOTOs
25258
123456
123457
123458
123459
25259
123410
123411
123412
123413
However, both tables are in relationship right now
Now, this is my goal to achieve
I have form called WA Switch Board where I have Datasheet View form with all WA records, fields are WA#, WAStatus, WAIssuedDate, IssuedBy, CompletionDate and etc but I have dropdown with with WAStatus with (In Field Today, On-Hold, In Approval, Cancelled, Close)
Now from the main switch board when authorized people try to change the status of permit to Closed I want recordset or count to loop through tblLOTO and give me a message box if associated LOTO/s status not equal to Close
In other word, if the associated LOTO/s are not close then the selected WA # in WA Switch Board can’t close
Here is the code I have been playing with no success
Private Sub PermitStatus_AfterUpdate()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * from qryLOTO where (WAAndPrefix)= " & Me.WAPrefix & " AND (LOTOStatusList) = "In Field Today, "On-Hold, "In Approval")
On Error Resume Next
DoCmd.SetWarnings False
''''''''''''''''''''''''''''''''
If rs.EOF Then
On Error Resume Next 'Exit Sub
DoCmd.SetWarnings False
If MsgBox("The selected LOTO " & WAPrefix.Value & " The WA # you trying close are associated with many LOTO/s, can't close this WA# unless associated LOTO/s are closed"),,"Warning !!! Please read carefully"
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub
I am looking forward to receive any help from any of you that will safe my life
Thanks & best regards,
Tamang