Filtering Data On Entry

I

iain

I'm trying to speed up data entry on a form in such a manner that when I
enter the first character in a field, it displays a list of all previously
stored values that begin with that character, then reduce the number of
choices as I type each character.

If the string that I want to enter is already listed I wish to select it
using the mouse, otherwise type a completely new string and use the enter key
or tab to the next field.

Can this be achieved with a Combo Box?

Does anyone onow of usefull links where I might find more information on
this technique?

Thanks,

Iain
 
W

Wayne-I-M

Hi

You can set the Auto Expand to Yes (in the Data column)
This will do what you want
 
I

iain

Thanks Wayne,

that was quick.

The Auto Expand is already set to 'yes'. Nothing happens when I type a
character in the field when creating a new record. In other words, I still
have to click on the down arrow to open up the combo box list of previous
data entries.
 
W

Wayne-I-M

Hi

Sorry for not getting back to you sooner - I have been away.

Open the form in design view and right click the combo.
Open the properties box
In the Event column select the Got Focus row
Right click and select build (...)
Select code
Add this (change ComboName to what it really is)

Private Sub ComboName_GotFocus()
Me.ComboName.Dropdown
End Sub

Good luck
 
W

Wayne-I-M

Just had a thought
If you are (or maybe) adding or searching for a record that it not already
on file you may want to add this to the combo.

Again change ComboName and also change TableName (to the table name of the
table that holds the records you are searching). Change ID to the name of
the primary field (of the table that you searching)

This, along wioth the OnFocus I already gave should sort out your problem.

Good luck

(don't forget to change ComboName, TableName and ID to what they really are
or it will not work)



Private Sub ComboName_NotInList(NewData As String, Response As Integer)
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim msg As String
msg = "'" & NewData & "' is not on file." & vbCr & vbCr
msg = msg & "Do you want to add New Record?"
If MsgBox(msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Set Db = CurrentDb
Set rs = Db.OpenRecordset("TableName", dbOpenDynaset)
rs.AddNew
rs![CDSurname] = NewData
rs.Update
Response = acDataErrAdded
End If
End Sub


Private Sub ComboName_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Me![ComboName])
Me.Bookmark = rs.Bookmark
End Sub
 
W

Wayne-I-M

Soory - should read what I send 1srt :)

change this
rs![CDSurname] = NewData

to
rs![*****] = NewData

Cahnge ***** to the name of the control that you are searching,
So if you are searching for a Surname and the name of the control (not the
table field) is ClientSurname it would be
rs![ClientSurname] = NewData

Searching a control called Cars it would be
rs![Cars NewData

etc
etc




--
Wayne
Manchester, England.



Wayne-I-M said:
Just had a thought
If you are (or maybe) adding or searching for a record that it not already
on file you may want to add this to the combo.

Again change ComboName and also change TableName (to the table name of the
table that holds the records you are searching). Change ID to the name of
the primary field (of the table that you searching)

This, along wioth the OnFocus I already gave should sort out your problem.

Good luck

(don't forget to change ComboName, TableName and ID to what they really are
or it will not work)



Private Sub ComboName_NotInList(NewData As String, Response As Integer)
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim msg As String
msg = "'" & NewData & "' is not on file." & vbCr & vbCr
msg = msg & "Do you want to add New Record?"
If MsgBox(msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Set Db = CurrentDb
Set rs = Db.OpenRecordset("TableName", dbOpenDynaset)
rs.AddNew
rs![CDSurname] = NewData
rs.Update
Response = acDataErrAdded
End If
End Sub


Private Sub ComboName_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Me![ComboName])
Me.Bookmark = rs.Bookmark
End Sub




--
Wayne
Manchester, England.



iain said:
Thanks Wayne,

that was quick.

The Auto Expand is already set to 'yes'. Nothing happens when I type a
character in the field when creating a new record. In other words, I still
have to click on the down arrow to open up the combo box list of previous
data entries.
 
I

iain

Thanks Wayne,

I'll have to try this out a few times to see if it does the trick, so it may
be a while before you hear from me.

Wayne-I-M said:
Soory - should read what I send 1srt :)

change this
rs![CDSurname] = NewData

to
rs![*****] = NewData

Cahnge ***** to the name of the control that you are searching,
So if you are searching for a Surname and the name of the control (not the
table field) is ClientSurname it would be
rs![ClientSurname] = NewData

Searching a control called Cars it would be
rs![Cars NewData

etc
etc




--
Wayne
Manchester, England.



Wayne-I-M said:
Just had a thought
If you are (or maybe) adding or searching for a record that it not already
on file you may want to add this to the combo.

Again change ComboName and also change TableName (to the table name of the
table that holds the records you are searching). Change ID to the name of
the primary field (of the table that you searching)

This, along wioth the OnFocus I already gave should sort out your problem.

Good luck

(don't forget to change ComboName, TableName and ID to what they really are
or it will not work)



Private Sub ComboName_NotInList(NewData As String, Response As Integer)
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim msg As String
msg = "'" & NewData & "' is not on file." & vbCr & vbCr
msg = msg & "Do you want to add New Record?"
If MsgBox(msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Set Db = CurrentDb
Set rs = Db.OpenRecordset("TableName", dbOpenDynaset)
rs.AddNew
rs![CDSurname] = NewData
rs.Update
Response = acDataErrAdded
End If
End Sub


Private Sub ComboName_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Me![ComboName])
Me.Bookmark = rs.Bookmark
End Sub




--
Wayne
Manchester, England.



iain said:
Thanks Wayne,

that was quick.

The Auto Expand is already set to 'yes'. Nothing happens when I type a
character in the field when creating a new record. In other words, I still
have to click on the down arrow to open up the combo box list of previous
data entries.

:

Hi

You can set the Auto Expand to Yes (in the Data column)
This will do what you want
--
Wayne
Manchester, England.



:

I'm trying to speed up data entry on a form in such a manner that when I
enter the first character in a field, it displays a list of all previously
stored values that begin with that character, then reduce the number of
choices as I type each character.

If the string that I want to enter is already listed I wish to select it
using the mouse, otherwise type a completely new string and use the enter key
or tab to the next field.

Can this be achieved with a Combo Box?

Does anyone onow of usefull links where I might find more information on
this technique?

Thanks,

Iain
 
I

iain

Thanks Ken,

this is quite a lot for me to work on, so it'll take some time before I get
it working, but I'll give it a whirl.

Iain
 
I

iain

Well Ken, I've had a go at this and it is very close to what I'm trying to
achieve.

The 'Find as you Type' function is probably what I need in the long run but
I've read it and it is way beyond my capabilities and understanding.

I'm having the following difficulties with your suggestion:

The form name is frmContents and the field name is Subjects, and the form
module now has 3 private subs for each of the events. As soon as I opened
the form after adding the list box, I now get a message box popping up "Enter
Parameter Value" i.e. frmContents!Subjects. I have to click the cancel
button on the message box, three times before the form is displayed.

The same thing happens when I try to type anything in the field. This list
box only filters the choice after I type everything I want into the text box,
but not as I type each character.

Any further suggestions?

Iain
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top