I have to side with Linq; DCount() would be better than DLookup().
I did rework your code a little
.... (this is untested)
Code:
Private Sub btnsrch_Click()
Dim strMedID As String
Dim varMed_ID As Variant ' can hold a NULL
Dim Msg, Style, Title
' Get Value from Medicaid_ID textbox on the Form:
strMedID = Me.SrchMed_ID
' Me.btnsrch.SetFocus
' Me.SrchMed_ID.SetFocus
' MedID = Me.SrchMed_ID.Text
'------------------
' for testing - comment or delete when debugging complete
MsgBox strMedID & ""
'------------------
varMed_ID = DLookup("[Medicaid_ID]", "Provider", "Medicaid_ID = '" & strMedID & "'")
If Len(varMed_ID & "") = 0 Then
' Medicaid_ID doesn't exist.
DoCmd.OpenForm "AddNewFile", , , , acFormAdd
Else
' Medicaid_ID exists.
Msg = "Medicaid ID Already Exists" & vbNewLine & vbNewLine & "Do not add to database." & vbNewLine & "Do not create another file folder." & vbNewLine & vbNewLine & "Would you like to update the database record. "
Style = vbYesNo + vbInformation + vbDefaultButton2
Title = "Information"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then 'User chose Yes.
DoCmd.OpenForm "UpdateCurrentFile", , , "[Medicaid_ID] = '" & strMedID & "'"
End If
End If
End Sub