Help with query

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

Guest

I keep getting an error message when I try and run this: COMPILE ERROR BLOCK IF
WITHOUT END IF.
I have changed things around but nothing seems to work

Private Sub MultiOK_Click()
On Error GoTo Err_multiOK_Click

If IsNull(Forms![Find contaminant,department,date]!Contaminant) Then
If IsNull(Forms![Find contaminant,department,date]!Department) Then
If IsNull(Forms![Find contaminant,department,date]!Date) Then
DoCmd.Close acForm, "Find contaminant,department,date"
'MsgBox "oops"
Exit Sub

End If

DoCmd.OpenQuery "Retreive Selected contaminant,department,date",
acNormal, acEdit
DoCmd.OpenForm "contaminant,department,date Display"
DoCmd.Close acQuery, "Retreive Selected contaminant,department,date"

DoCmd.Close acForm, "Find contaminant,department,date"
DoCmd.SelectObject acForm, "contaminant,department,date Display"

Exit_multiOK_Click:
Exit Sub
 
Well, you have three IF and one EndIf. Perhaps you want to add two more
endIf lines above or below the endif line you currently have.

Or perhaps you simply want
IF IsNull(Forms![Find contaminant,department,date]!Contaminant) _
Or IsNull(Forms![Find contaminant,department,date]!Department) _
Or IsNull(Forms![Find contaminant,department,date]!Date) Then

Exit Sub
End if
 
I have changed it but now I get a syntax error. Desperate to get this to work
Thanxs for your help
If IsNull(Forms![Find contaminant,department,date]!Contaminant)
Or IsNull(Forms![Find contaminant,department,date]!Department) _
Or IsNull(Forms![Find contaminant,department,date]!Date) Then
DoCmd.Close acForm, "Find Contaminant,department,date"
'MsgBox "oops"
Exit Sub

Exit Sub
End If


John Spencer said:
Well, you have three IF and one EndIf. Perhaps you want to add two more
endIf lines above or below the endif line you currently have.

Or perhaps you simply want
IF IsNull(Forms![Find contaminant,department,date]!Contaminant) _
Or IsNull(Forms![Find contaminant,department,date]!Department) _
Or IsNull(Forms![Find contaminant,department,date]!Date) Then

Exit Sub
End if

mwest said:
I keep getting an error message when I try and run this: COMPILE ERROR
BLOCK IF
WITHOUT END IF.
I have changed things around but nothing seems to work

Private Sub MultiOK_Click()
On Error GoTo Err_multiOK_Click

If IsNull(Forms![Find contaminant,department,date]!Contaminant) Then
If IsNull(Forms![Find contaminant,department,date]!Department) Then
If IsNull(Forms![Find contaminant,department,date]!Date) Then
DoCmd.Close acForm, "Find contaminant,department,date"
'MsgBox "oops"
Exit Sub

End If

DoCmd.OpenQuery "Retreive Selected contaminant,department,date",
acNormal, acEdit
DoCmd.OpenForm "contaminant,department,date Display"
DoCmd.Close acQuery, "Retreive Selected contaminant,department,date"

DoCmd.Close acForm, "Find contaminant,department,date"
DoCmd.SelectObject acForm, "contaminant,department,date Display"

Exit_multiOK_Click:
Exit Sub
 
You need a continuation (a space and an underscore) at the end of the first
line:

If IsNull(Forms![Find contaminant,department,date]!Contaminant) _
Or IsNull(Forms![Find contaminant,department,date]!Department) _
...

Without it, the if statement ends without "then", and a new statement begins
with "Or isNull...".


mwest said:
I have changed it but now I get a syntax error. Desperate to get this to work
Thanxs for your help
If IsNull(Forms![Find contaminant,department,date]!Contaminant)
Or IsNull(Forms![Find contaminant,department,date]!Department) _
Or IsNull(Forms![Find contaminant,department,date]!Date) Then
DoCmd.Close acForm, "Find Contaminant,department,date"
'MsgBox "oops"
Exit Sub

Exit Sub
End If


John Spencer said:
Well, you have three IF and one EndIf. Perhaps you want to add two more
endIf lines above or below the endif line you currently have.

Or perhaps you simply want
IF IsNull(Forms![Find contaminant,department,date]!Contaminant) _
Or IsNull(Forms![Find contaminant,department,date]!Department) _
Or IsNull(Forms![Find contaminant,department,date]!Date) Then

Exit Sub
End if

mwest said:
I keep getting an error message when I try and run this: COMPILE ERROR
BLOCK IF
WITHOUT END IF.
I have changed things around but nothing seems to work

Private Sub MultiOK_Click()
On Error GoTo Err_multiOK_Click

If IsNull(Forms![Find contaminant,department,date]!Contaminant) Then
If IsNull(Forms![Find contaminant,department,date]!Department) Then
If IsNull(Forms![Find contaminant,department,date]!Date) Then
DoCmd.Close acForm, "Find contaminant,department,date"
'MsgBox "oops"
Exit Sub

End If

DoCmd.OpenQuery "Retreive Selected contaminant,department,date",
acNormal, acEdit
DoCmd.OpenForm "contaminant,department,date Display"
DoCmd.Close acQuery, "Retreive Selected contaminant,department,date"

DoCmd.Close acForm, "Find contaminant,department,date"
DoCmd.SelectObject acForm, "contaminant,department,date Display"

Exit_multiOK_Click:
Exit Sub
 
Back
Top