(looks like) simple acces question: search in a form

Dinictus

Board Regular
Joined
Mar 19, 2002
Messages
162
Hi,

I have a very basis data structure with name, adress and phone number.
Now, I want a form in which I can type the first letters of a name and then acces must automatically give the rest of the record.

so if I type "Di"

Acces already gives Dinictus, Rotterdam, 010-5763663.

It must be simple but I cant figure it out!
The stupid thing is, I built this in excell and it works fine but acces must be way better fot this kinds of things isn'y it?

Can anyone point me in the right direction?
Thanks al lot again.
:coffee:
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
It can be done using a little VB code in the change event of your input field. The way to do it would be to count the number of records returned after each change to the input field.

I've had a go and got this working

Private Sub txtInput_Change()

x = DCount("FirstName", "NameSearch", "firstName like '" & txtInput.Text & "*'")
If x = 1 Then
rtn = DLookup("FirstName", "NameSearch", "FirstName like '" & txtInput.Text & "*'")
txtName.SetFocus
txtName.Text = rtn
End If

End Sub

You will have to tinker with the code a little to catch duplicate names or ones which are similar but you should get the drift.

If you have a name like Ben and also Benny typing Ben will not work as it sees Ben and Benny so the return count is >1.

Needs a little more thought but hope this help you on the way

Chris
 
Upvote 0
you could use a combo box to make the name selection and use its afterupdate event to run the filter code for the rest of your data.

Peter
 
Upvote 0
I'm not sure I follow you ....

The Op said he wanted to type the first parts of the word and let the DB fill in the rest - i assumed when the first part of the word was unique.

How would a combo box help with this ?
 
Upvote 0
A combo box by default will autocomplete the word as you type it in. soon as you have your word hit enter and you have what you want.

Peter
 
Upvote 0

Forum statistics

Threads
1,221,638
Messages
6,160,994
Members
451,682
Latest member
ogoreo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top