I created a button that searches for what i put in a text box. The search works perfectly if i click the button after entering my text. What I was wondering is, how do i make it work by hitting "enter" after typing my text?
You're welcome. Good luck with your project.OMG!!!!! thank you soo much it has caused me headaches that every time i hit enter after putting in my text and just go oh right gotta hit the button
Hmm, why do you have/need three different buttons for searching? Can you post a screenshot of your search form?New question, same topic. I needed to go with multiple search options in the database: Name, ID, SID. I made a search for each line but since its 3 different buttons I cannot hit enter to search. Is there a way to keep all 3 and just have the enter work if the field has data?
I would suggest maybe using three textboxes and one button. Or better yet, one textbox, an option group to select the search type, and one button.View attachment 100187
Some soldiers do not have SIDs but 95% do so its a valid search, DoD ID everyone has but hard to remember at the time to search, name is fastest way to search of course searches by last name. I could put them all into 1 button but was seeing if there was a way to keep the 3.
Not necessarily "together." Instead, think of it as three separate branches. One button to decide which route to take (or, which search to make).Ok so what i feared is what would have to happen. Have to make 1 button and put all three types of search together. Thank you
Well, don't give up just yet. Assuming the user will fill in the desired Textbox to search before hitting Enter, then you could remove the Default setting and simply use the AfterUpdate event of each Textbox to perform the search (by calling the corresponding button code).yeah I know not "together" but 1 text box instead of 3 is all I meant, I kinda like the simplicity that it is now so I will just tell the few that want the "enter" option they are SOL.
If Me.cboChoice.Value = "SID" Then
SIDSearch ("' & txtChoice & '")
ElseIf Me.cboChoice.Value = "DoD ID" Then
DoDSearch (" & txtChoice & ")
ElseIf Me.cboChoice.Value = "Name" Then
NameSearch ("' & txtChoice & '")
End If
Dim dbCurr As DAO.Database
Dim rstDod As DAO.Recordset
Dim strDoD As String
Set dbCurr = CurrentDb()
Set rstDod = Me.Recordset
strDoD = Me.txtChoice.Value
rstDod.FindFirst "[DoD ID] = " & strDoD
If rstDod.NoMatch Then
MsgBox "Record not found for DoD ID# " & strDoD
End If
Me.txtChoice.Value = ""
Set rstDod = Nothing
Set dbCurr = Nothing
Which line is highlighted when you go to debug mode?Ok I changed it to 1 button but I am getting type mismatch errors after the search has happened. I enter the appropriate info and the search finds what I'm looking for and then I get a type mismatch error.
Thats my button codeCode:If Me.cboChoice.Value = "SID" Then SIDSearch ("' & txtChoice & '") ElseIf Me.cboChoice.Value = "DoD ID" Then DoDSearch (" & txtChoice & ") ElseIf Me.cboChoice.Value = "Name" Then NameSearch ("' & txtChoice & '") End If
Code:Dim dbCurr As DAO.Database Dim rstDod As DAO.Recordset Dim strDoD As String Set dbCurr = CurrentDb() Set rstDod = Me.Recordset strDoD = Me.txtChoice.Value rstDod.FindFirst "[DoD ID] = " & strDoD If rstDod.NoMatch Then MsgBox "Record not found for DoD ID# " & strDoD End If Me.txtChoice.Value = "" Set rstDod = Nothing Set dbCurr = Nothing
That's what all the search functions look like with subtle changes for DoD ID, SID, and Name.
Hi. Welcome to AWF!I am facing a problem in search box. Guide me best tips and trick for finding large amount of data from old records.