Open Form command error on field value

F

friesr

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."
 
F

friesr

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top