My bad it's under Class Objects
No problem. A form is a Class Object.
Try this. It's unclear where the IndexFacilityAdj and ReportingYearAdj are located. It they are textboxes on the form, code is OK.
The Me. prefix refers to controls on the forms, actually the CONTENTS or VALUES of those controls.
Brackets must be used to refer to the values of fields in the form's recordsource that are not on the form.
Brackets are also REQUIRED for any object on the form that contains spaces in its name.
An image of the form in design mode posted here would be helpful to clarify.
Code:
Option Compare Database
Option Explicit
Private Sub btnSch1Next_Click()
Dim IndFac As String
Dim RepYr As Integer
Dim SLO As String
If IsNull(Me.IndexFacility) Then
MsgBox "Index and Facility not selected.", vbOKOnly, "Warning"
Exit Sub
End If
If IsNull(Me.ReportingYear) Then
MsgBox "Reporting Year not entered.", vbOKOnly, "Warning"
Exit Sub
End If
'above entries OK, so continue
If Not IsNull(Me.SulphurLimitOption) Then
If Me.SulphurLimitOption = "Pool Average" Then
If Me.IndexFacilityAdj = Me.IndexFacility And Me.ReportingYearAdj = Me.ReportingYear Then
DoCmd.OpenForm "frm_Sch1 Adjust", acNormal, , , acFormEdit, acWindowNormal
Else
DoCmd.OpenForm "frm_Sch1 Adjust", acNormal, , , acFormAdd, acWindowNormal
End If
Else
If Me.ReportingFacility = Me.IndexFacility And Me.ReportingYearAnx = Me.ReportingYear Then
DoCmd.OpenForm "frm_Sch1 Annex", acNormal, , , acFormEdit, acWindowNormal
Else
DoCmd.OpenForm "frm_Sch1 Annex", acNormal, , , acFormAdd, acWindowNormal
End If
End If
Else
MsgBox "Sulphur Limit Option not selected.", vbOKOnly, "Warning"
End If
End Sub
Note: added Red code so that execution does not fall through when data is missing.