Hey folks. I have some code that works fine, but I'd like to add more to it. Here is the code:
Now, as some of you may notice, this is a search function called by a button on a pop-up form, designed to find records on another form. The people I work with have trouble with the normal find dialog that pops up, so I've gone this route (don't ask me WHY they have troubles, I can't seem to figure that one out).
One thing that this code does not do, is display a message when the search either A) Fails outright, or B) cannot find any more records (ie, has already found 5 smiths, no more in db).
Anyone have improvements on the code as it is now, or ideas on how to add the msgbox that I mention?
Thanks!
Code:
Dim optArray As Variant, searchText As String, frmName, optValue As Object
optArray = Array("Last_Name", "First_Name", "CertNo", "SSN")
Set frmName = Forms("frm_CertifiedApplicants")
Set optValue = frmName.Controls(optArray(Me.searchFrame))
If Me.txt_SearchText = Null Or Me.txt_SearchText = "" Then
Exit Sub
Else
searchText = Me.txt_SearchText.Value
If searchText = prevSearchText And Me.searchFrame.Value = prevSearchValue Then
frmName.SetFocus
optValue.SetFocus
DoCmd.FindNext
Else
frmName.SetFocus
optValue.SetFocus
DoCmd.FindRecord searchText, acAnywhere, False, acSearchAll, True, acCurrent, True
prevSearchText = searchText
prevSearchValue = Me.searchFrame.Value
End If
End If
Me.SetFocus
Me.txt_SearchText.SetFocus
Now, as some of you may notice, this is a search function called by a button on a pop-up form, designed to find records on another form. The people I work with have trouble with the normal find dialog that pops up, so I've gone this route (don't ask me WHY they have troubles, I can't seem to figure that one out).
One thing that this code does not do, is display a message when the search either A) Fails outright, or B) cannot find any more records (ie, has already found 5 smiths, no more in db).
Anyone have improvements on the code as it is now, or ideas on how to add the msgbox that I mention?
Thanks!