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

Check before update Check Box

Status
Not open for further replies.

ragu111

MIS
Aug 15, 2002
129
AE
in my form (Continuous Forms)i have below fields

Doc_Submit_Date
Inv_No
Status (Check Box)

before updating the Check Box i want to make sure the Doc_Submit_Date, Inv_No fields are updated. of not updated the system should not allow the user to check the check box

i'm using below code but no luck


Code:
Private Sub Status_BeforeUpdate(Cancel As Integer)
If Trim$(Me.Doc_Submit_Date.Value & "") = "" Then
    MsgBox ("Document Submission Date is not updated")
If Trim$(Me.Inv_No.Value & "") = "" Then
    MsgBox ("Invoice for this job is not updated")
Else
    Me.Status.Locked = False
    
End If
End If
End Sub

can someone help

ragu [pc]
 
Maybe you can get it to work if you play around with the OldValue-property. I used it for the DocSumbitDate. This is what I created.


Code:
Public Sub Form_current()
    Dim DocSubmitDateOld As Date
    
    'reset status to locked
    Me.Status.Locked = True
     
     'grab the old value
     DocSubmitDateOld = Me.DocSubmitDate.OldValue
    'I created an unbound textbox to see if it holds the OldValue     
     Me.DocSubmitDateOld = DocSubmitDateOld
  
    End Sub
 
Private Sub Status_GotFocus()
        If Me.Status.Locked = True Then
            MsgBox ("Document Submission Date is not updated")
        End If
End Sub

Private Sub DocSubmitDate_AfterUpdate()
       'unlock when the oldvalue is not equal to current value 
       If Me.DocSubmitDate <> Me.DocSubmitDateOld Then
            Me.Status.Locked = False
        Else: Me.Status.Locked = True
        End If
End Sub



Pampers [afro]
Just back from holiday...
that may it explain it.
 
Instead of using the OldValue, you can also use the onChange-event, like

Code:
Private Sub DocSubmitDate_Change()
    Me.Status.Locked = False
End Sub

Private Sub Form_Current()
    Me.Status.Locked = True
End Sub


Private Sub Status_GotFocus()
        If Me.Status.Locked = True Then
            MsgBox ("Document Submission Date is not updated")
        End If
End Sub

Pampers [afro]
Just back from holiday...
that may it explain it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top