In your case you are using what is called a one line statement
If (true) then MsgBox "No End If required!"
This works and doesn't require an End If
statement because it's a one-liner.
Because you do have an End If
statement that's why the error occurs, because you trying to end an If
statement which has not been started ( 2 one-liners ).
In C# you for example a ;
semi-colon acts as a line separator. In VB/VBA you use the Return key to separate lines.
You can do exactly the same thing two other ways
1)
If (true) then _
MsgBox "No End If required!"
2)
If (true) then
MsgBox "End If required!!!"
End If
However in your case it seems that a more suitable decision would be to use a combination of If
and ElseIf
like this
If IDtype = "UK" Then
sqluserfix = " & UserId & "
ElseIf IDtype = "NE" Then
sqluserfix = "(select USER_ID from USER_PARAMS where USER_ID2='" & UserId & "')"
End If
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…