Syntax?

hi there

Registered User.
Local time
Today, 16:38
Joined
Sep 5, 2002
Messages
171
here's an easy one. i just created a little form where i hide some controls based on a selection made in a combo box. he's the code:

Private Sub RequirementType_BeforeUpdate(Cancel As Integer)

If (Me.RequirementType <> "Recordkeeping Requirement") Then
Me.RecordkeepingSource.Visible = False
Me.RecordLocation.Visible = False
Me.RecordRetentionTime.Visible = False
End If

End Sub

everything works alright, but originally i had placed the statement:

Cancel = True

before closing the If statement. when i did this Access locked me in the RequirementType field after making my selection. In a previous application where i was doing some data validation i was advised to use the "Cancel = True" line to be safe.

e.g.

If (Me.Value1 > Me.Value2) Then
MsgBox "Value 1 cannot be greater than Value 2", vbExclamation
Me.Value1.undo
Cancel = True
End If

basically i'm not sure what the "Cancel = True" does and when should i use it. could someone explain this to me?

thanks a lot.
 
hi pat. thanks for the response. i was told to use that "Cancel = True" statement and i could figure out what it was doing. as soon as i posted that thread i realized that i forgot the Else part of the code, but thanks for the suggestion. it was helpful.
 

Users who are viewing this thread

Back
Top Bottom