Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching Qeustion

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
hello everybody i need to know if theres a way to have a text box on top of my form were i can enter a persons first few letters of the last name and the people with those letters come up below with rows. for example if i put in "A" i would like all the people with the last name starting with a to show.
 
Use a combobox instead of a list box and it will do just as you wish.

 
hey rollie i have the same question what do u mean by combobox and were can i get more info on it. i want to be able to search the database by the first few letters of the last name or first. is there documentation on this somewhere. Thanks, PAUL

 
Hello.

If I understood you correctly you need to create a query that has for criteria the text you type in the text box on your form.

To be able to view the results on the same form you will have to insert the query as a subform on the form and then it will display the results you want.

So start by creating a query that gets the criteries from the tesxt box on your form and then you just insert the query as a subform. So you can view the results on the form.

Hope this helps a little.
 
I want to create a text box in a form that will search the last name of a client. The search should be activiated by clicking a command button. Furthermore, in the text box I need to be able to type the first letter or letters of the clients name. I think this deserves a star for the effort. Thanks in advance for your help. Need answer ASAP. Thanks, PAUL

 
If you are still having problems, email me at Rollie@bwsys.net and I will send you the code of a form that does just what I believe you wish to do. I am new to this forum and can never get back to where I last was. That is why I did not respond earlier.

Rollie
 
I do three types os searches or 'picks' that you should consider. One is to enter a form textbox with enough of the leading characters to make the search unique. The I use the following code.

Private Sub cmdFyndr_Click()
Dim rs As Object, db As Database, str1 As String

If Me.txtFyndr = Null Then Exit Sub

Set db = CurrentDb()
Set rs = Me.RecordsetClone
rs.MoveLast: rs.MoveFirst
str1 = Me.txtFyndr

Do While Not rs.EOF
If rs!LName >= str1 Then
Exit Do
End If
rs.MoveNext
Loop

Me.txtFyndr = ""
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
rs.close
set rs = nothing
db.close
set db = nothing

This will kick me out at the first value greater than my input. I do have to have SELECTED the records in an ORDER

This is what the RECORD SOURCE is in the form:

SELECT HHOLD.HID, HHOLD.LName, HHOLD.FName, HHOLD.Salu, HHOLD.Addr, HHOLD.City, HHOLD.ST, HHOLD.ZIP, HHOLD.Phone1, HHOLD.Phone2, HHOLD.NewsLtr, HHOLD.IsChurch, HHOLD.IsOrg, HHOLD.email, HHOLD.Code
FROM HHOLD
ORDER BY HHOLD.LName, HHOLD.FName;


The second way is similar except it uses "INSTR" to find imbedded code in a field.

The third way is a combo box.

The combo box data source looks like this:

SELECT PkgNamLst.PID, PkgNamLst.PName
FROM PkgNamLst
ORDER BY PkgNamLst.PName;

Then an even "afterupdate" calles the following code.

Private Sub Combo8_AfterUpdate()
Dim db As Database, ps As Object, SSQL As String
Me.txtPID = Me.Combo8
SSQL = "SELECT * FROM PkgNamLst WHERE PkgNamLst.PID = "
SSQL = SSQL & Me.txtPID & ";"
'MsgBox SSQL
Set db = CurrentDb()
Set ps = db.OpenRecordset(SSQL)
Me.txtPName = ps.PName
Me.txtNumRms = ps.Rooms
Me.txtNumTics = ps.Tics
Me.txtNumAtTbl = ps.AtTbl
ps.Close
Set ps = Nothing
db.Close
Set db = Nothing
End Sub

Using the combo box I just click to set focus and then type in enough letters to "find." it.

Hope this helps.

Rollie
 
im not understanding it because this is coming out of your DB but i thing i need to replace Lname with mine which is Last_Nm now on the record source for the form i replace HHOLD (which i think is a table with mine which is Claim.plus all fields wanted" and also if i want things from another table i would put from "client(my table).""all fields wanted" do u think thats all i would need to change?
also i put the first query in the command button source or the button? Thanks, PAUL

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top