I have no idea what I'm doing wrong. Esentially what I want to do is create a code that if a facility name equals a specific facility I want to run a macro.
For some reason i've run into a problem that since i'm using a continuous form, it only queries the first record. So I've attempted to create a code that would loop through all the records, but unfortunately I am not doing it correctly.
Here's my code:
Private Sub Form_Close()
DoCmd.OpenForm "Background"
If Me.Facility_Name = "Santaquin" Then
MsgBox "test does this work SQ", vbOKOnly
' DoCmd.SetWarnings (Off)
DoCmd.RunMacro "Santaquin Macro"
'DoCmd.SetWarnings (WarningsOn)
Else
GoTo NextRecord
Do Until EndRecord
End
Loop
End Sub
I get an error saying Block If without End If and I can find where I need to put the end if...
Then if I put the end if right befoer the end sub, I get a Label not defined error.
I have no idea what i should be doing, any help would be much appreciated.
Thanks!
Julie
For some reason i've run into a problem that since i'm using a continuous form, it only queries the first record. So I've attempted to create a code that would loop through all the records, but unfortunately I am not doing it correctly.
Here's my code:
Private Sub Form_Close()
DoCmd.OpenForm "Background"
If Me.Facility_Name = "Santaquin" Then
MsgBox "test does this work SQ", vbOKOnly
' DoCmd.SetWarnings (Off)
DoCmd.RunMacro "Santaquin Macro"
'DoCmd.SetWarnings (WarningsOn)
Else
GoTo NextRecord
Do Until EndRecord
End
Loop
End Sub
I get an error saying Block If without End If and I can find where I need to put the end if...
Then if I put the end if right befoer the end sub, I get a Label not defined error.
I have no idea what i should be doing, any help would be much appreciated.
Thanks!
Julie