Here is my code it works unless I click cancel on the input box. It hangs up on the line I have indicated in red. How can I get it to recognize the cancel button? Thanks.
Private Sub provid_btn_Click()
Dim MedID As String
' Get Value from Medicaid_ID textbox on the Form:
Me.provid_btn.SetFocus
Me.srchprovid.SetFocus
MedID = Me.srchprovid.Text
If IsNull(DLookup("[Sak_Prov]", "Sak_Prov", "Sak_Prov = '" & srchprovid & "'")) Then
' NAME is Null because the Medicaid_ID doesn't exist.
DoCmd.OpenForm "Sak_ProvForm", , , , acFormAdd
' NAME is not Null because the Medicaid_ID does exist.
Else
DoCmd.OpenForm "UpdateCurrentFile", , , , acFormAdd
Dim frm As Form, strMsg As String
Dim strInput As String, strFilter As String
' Open UpdateCurrentFile form in Form view.
DoCmd.OpenForm "UpdateCurrentFile"
' Return Form object variable pointing to UpdateCurrentFile form.
Set frm = Forms!UpdateCurrentFile
strMsg = "Provider ID is already on file." & (Chr(13)) & (Chr(13)) & "Enter Medicaid ID and Update all information per instructions & policy. "
' Prompt user for input.
strInput = InputBox(strMsg)
' Build criteria string.
strFilter = BuildCriteria("Medicaid_ID", dbText, strInput)
' Set Filter property to apply filter.
frm.Filter = strFilter
' Set FilterOn property; form now shows filtered records.
frm.FilterOn = True
Forms!UpdateCurrentFile!ProvID_iC.SetFocus 'Sets focus to Control ProvID_iC
End If
End Sub