Open Form command error on field value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following command to open a form:

Private Sub Command38_Click()
On Error GoTo Err_Command38_Click

Dim stDocName As String
Dim stLinkCriteria As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

stDocName = "PR"

stLinkCriteria = "[ID]=" & Me![Text35]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command38_Click:
Exit Sub

Err_Command38_Click:
MsgBox Err.Description
Resume Exit_Command38_Click

End Sub

I want to add a if then statement that will check the value of the field
"Type" if the value is not "PR" then will give an error "Incorrect form for
type of review."
 
Never mind,

Figured it out... I just added

If Me.Type <> "PR" Then
MsgBox "Incorrect form for type of review!"
Exit Sub
End If


Thx
 
Back
Top