November 5th, 2009, 08:19 PM
posted to microsoft.public.access.forms
|
|
If, Then, Else
That was it! Thank you.
"Dirk Goldgar" wrote:
"Ann" wrote in message
...
Hi,
I'm a bit confused and hope someone can help. I'm just learning code and
can't figure out why I keep getting an compile error; Else Without If on
the
following code. Thanks in advance.
Private Sub Command930_Click()
On Error GoTo Err_Command930_Click
Dim stDocName As String
Dim stLinkCriteria As String
If SSN.Value = -1 And ysnName.Value = -1 _
And Recipient_of_PHI = "Entity" Or Recipient_of_PHI = "Person" Then _
stDocName = "frmAction1-5"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
stDocName = "frmAction5"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_Command930_Click:
Exit Sub
Err_Command930_Click:
MsgBox Err.Description
Resume Exit_Command930_Click
End Sub
I believe it's because you have a line-continuation character after the
keyword Then:
And Recipient_of_PHI = "Entity" Or Recipient_of_PHI = "Person" Then _
It should just be
And Recipient_of_PHI = "Entity" Or Recipient_of_PHI = "Person" Then
For a block If, the statements that follow the If are not continuations of
the If statement.
--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html
(please reply to the newsgroup)
|