I have a problem making the code for an "If" statement and was hoping that you could help me.
I have a table with the following relevant fields:
tblPunchList
PunchListID pk autonumber
dtCloseContractor date/time
dtCloseClient date/time
StatusContractor yes/no
StatusClient yes/no
On my main form I have two separate option groups; "fogStatusContractor" and "fogStatusClient" referring to the above fields. Both option groups are either "Open" or "Closed" (Closed=Yes, Open=no). I like to prevent users from Closing the "fogStatusClient" option group before the "fogStatusContractor" is "closed", i.e. if "fogStatusContractor" is Open (StatusContractor field in table equal "No"), then "fogStatusClient" must be "Open" (StatusClient field in table equal "No").
I write the date into my table, when items are closed.
CODE
Private Sub fogStatusClient_AfterUpdate()
Me.txtdtPLCloseClient = Date
End Sub
Private Sub fogStatusClient_BeforeUpdate(Cancel As Integer)
If (Me.StatusContractor = False) Then
'MsgBox "Settting Date for Contractor Closed: " & Now()
Me.StatusClient = False
MsgBox "You can not close the item before the item has been closed by the Contractor"
Else
MsgBox "Settting Date for Client Close: " & Date
Me.txtdtPLCloseClient = Date
Me.cbofkCloseClientID = lngMyEmpID
Me.StatusClient = True
End If
End Sub
Me.txtdtPLCloseClient = Date
End Sub
Private Sub fogStatusClient_BeforeUpdate(Cancel As Integer)
If (Me.StatusContractor = False) Then
'MsgBox "Settting Date for Contractor Closed: " & Now()
Me.StatusClient = False
MsgBox "You can not close the item before the item has been closed by the Contractor"
Else
MsgBox "Settting Date for Client Close: " & Date
Me.txtdtPLCloseClient = Date
Me.cbofkCloseClientID = lngMyEmpID
Me.StatusClient = True
End If
End Sub
Ultimately, I do not want to have the message boxes to appear, but these are just used for information during development. Currently, the above code does not prevent a change in "StatusClient" even though "If" statement is not valid. Can some one help?
Lastly, what is a good syntax for an option group control? I have currently used fog for Frame Option Group.