ArcherSteve
Perpetually Confused
- Local time
- Yesterday, 19:09
- Joined
- Jan 10, 2004
- Messages
- 48
Here's the code...
I keep on getting the same error message "Runtime Error '2185': You can't reference a property or method for a control unless the control has focus." on the line of code " strArcherRef = ID.Text". I've spent some good time on this and still can't figure out why. Any ideas?
Thanks,
Steve
Code:
Private Sub Command53_Click()
Dim strArcherRef As String
Dim strSearch As String
'Check txtSearch for Null value or Nill Entry first.
If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------
'Performs the search using value entered into txtSearch
'and evaluates this against values in ID
DoCmd.ShowAllRecords
DoCmd.GoToControl ("First")
DoCmd.FindRecord Me!txtSearch
First.SetFocus
strArcherRef = ID.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
'If matching record found sets focus in ID and shows msgbox
'and clears search control
If strArcherRef = strSearch Then
ID.SetFocus
txtSearch = ""
'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub
I keep on getting the same error message "Runtime Error '2185': You can't reference a property or method for a control unless the control has focus." on the line of code " strArcherRef = ID.Text". I've spent some good time on this and still can't figure out why. Any ideas?
Thanks,
Steve