Unanswered: help with search button to disable another command button
I have a search button programmed and would like to have a button called "cmdeditcustomer" be disabled if no records match the search criteria. I am unsure of what code needs to be written and where it needs to be I know the simple line of code "me.cmdeditcustomer.enabled = false" does the trick but I also know that I would need some sort of a conditional statement for this to work. Here is my code for the search button, I am using Access 07.
Dim strWhere As String
Dim lnglen As Long
If Not IsNull(Me.srchtxtlastname) Then
strWhere = strWhere & "([Lastname] = """ & Me!srchtxtlastname & """) AND "
If Not IsNull(Me.srchtxtfirstname) Then
strWhere = strWhere & "([Firstname] = """ & Me!srchtxtfirstname & """) AND "
If Not IsNull(Me.srchtxtemail) Then
strWhere = strWhere & "([Email] = """ & Me!srchtxtemail & """) AND "
If Not IsNull(Me.srchtxtphone) Then
strWhere = strWhere & "([Phone] = """ & Me!srchtxtphone & """) "
lnglen = Len(strWhere) - 5
If lnglen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Me.cmdeditcustomer.Enabled = False
Me.cmdregister.Enabled = False
strWhere = Left$(strWhere, lnglen)
Me.cmdeditcustomer.Enabled = True
Me.cmdregister.Enabled = True