Walshie1987
Technical User
- Oct 5, 2006
- 100
Hi, i have a text box and when i enter a number (Reqnumber)into it and click search it takes me to that record, now though i am doing another database and want to advance alittle and have two text boxes, i want to enter a first name in one and a surname in the other, and if a record is found which matches both boxes then i want it to be displayed on the screen.
This is the code i have for just one text box:
Private Sub cmdSearch_Click()
'Check Search Box for Blank Value
DoCmd.RunMacro ("gotonew")
If Trim(Me![txtSearch] & " ") = "" Then
MsgBox "Please Enter Req Number!", vbOKOnly, "No Req Number"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------
Dim Search As String
Search = txtSearch
DoCmd.ShowAllRecords
DoCmd.GoToControl ("ReqNumber")
DoCmd.FindRecord Me!txtSearch
DoCmd.GoToControl ("ReqNumber")
ReqNumber.SetFocus
'If Req Number found goes to record
If ReqNumber = Search Then
MsgBox "Req Found: " & txtSearch, , "Congratulations!"
ReqDate.SetFocus
txtSearch = ""
'If Req Number not found goes to input sheet
Else
DoCmd.RunMacro ("GoToNew")
UserSelection = MsgBox(" Req Not Found, Add Req?", vbYesNo)
Select Case UserSelection
Case 6
DoCmd.RunMacro ("GoToNew")
ReqNumber = Search
ReqDate.SetFocus
Case 7
DoCmd.RunMacro ("GoToNew")
txtSearch = Null
txtSearch.SetFocus
End Select
End If
End Sub
Can anyone Help?
Thanks
This is the code i have for just one text box:
Private Sub cmdSearch_Click()
'Check Search Box for Blank Value
DoCmd.RunMacro ("gotonew")
If Trim(Me![txtSearch] & " ") = "" Then
MsgBox "Please Enter Req Number!", vbOKOnly, "No Req Number"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------
Dim Search As String
Search = txtSearch
DoCmd.ShowAllRecords
DoCmd.GoToControl ("ReqNumber")
DoCmd.FindRecord Me!txtSearch
DoCmd.GoToControl ("ReqNumber")
ReqNumber.SetFocus
'If Req Number found goes to record
If ReqNumber = Search Then
MsgBox "Req Found: " & txtSearch, , "Congratulations!"
ReqDate.SetFocus
txtSearch = ""
'If Req Number not found goes to input sheet
Else
DoCmd.RunMacro ("GoToNew")
UserSelection = MsgBox(" Req Not Found, Add Req?", vbYesNo)
Select Case UserSelection
Case 6
DoCmd.RunMacro ("GoToNew")
ReqNumber = Search
ReqDate.SetFocus
Case 7
DoCmd.RunMacro ("GoToNew")
txtSearch = Null
txtSearch.SetFocus
End Select
End If
End Sub
Can anyone Help?
Thanks