Please see if this works:
Code:
Private Sub GoToBoM_btn_Click()
Dim S As String, BoMNo As String
Userinput:
S = InputBox("Please enter BoM Number", "BoM Number", "BoMNo")
If S = "" Then Exit Sub
'user hit cancel
Me.Filter = "BoMNo Like ""*" & S & "*"""
Me.FilterOn = True
'user inputs last four digits of number - if record exists, that record is populated on the form
'if the record is not found, the below is supposed to occur
'the Else statement works as expected. However, the initial if function is appearing even when the digits entered
'match an existing record. I've tried multiple configurations, and cannot figure out how to prevent this occurence.
'Can anyone advise?
'If BoMNo Like "" Then
If Me.Recordset.RecordsetCount =0 'you applied a filter, if no record found the form will be empty
If MsgBox("BoM Number not found. Please check the BoM Number and try again.", vbRetryCancel, "No Data") = vbRetry Then
GoTo Userinput 'reshow the input box
Else
DoCmd.Close acForm, "NPSU_Updt_frm", acSaveNo 'close the form
End If
End If
End Sub
Cheers,