Link to home
Start Free TrialLog in
Avatar of cisilay
cisilay

asked on

Auto-Complete using previously entered values in Access 2007

Hi,
When I entering new data to a new record in a text type field in Access 2007, what's the way of "auto-complete this field using previously entered values" ?
Thanks
Avatar of Markus Fischer
Markus Fischer
Flag of Switzerland image

Just copying the previous value is Ctrl+?

If you want to create a combo, let's imagine the source of your form is Table1 and the field is Field1, you would use this Row Source:

    SELECT DISTINCT Field1 FROM Table1 WHERE Field1 Is Not Null;

And add this to the AfterUpdate event:

Private Sub cboField1_AfterUpdate()
    cboField1.Requery
End Sub

Good luck!
(°v°)
Avatar of cisilay
cisilay

ASKER

I will give you an example from excel :
I enter a text to the cell a1 (Elvis Presley)
When I go the cell b1, and begin to enter (Elvis Presley) again, this cell remember the previous value and auto complete the cell with this word. If you want to enter to the next cell (Elvis Costello), you have to wait till the beginning of (Costello) to auto complete. The question is, can I use the same facility in access 2007 and how ?
And don't forget, I'm a novice and I need your help more detailed. Where and how can I enter these expressions..
Thanks.
Perhaps Access 2007 has this built-in, I wouldn't know. Up to Access 2003, I know that my suggestion above is a good solution.

However, it requires some skills in Access (creating a combo box), in queries (create a DISTINCT query) and in VB (creating the event procedure).

Let's start with the combo box.

Right-click your text box and select (Change To | Combo Box). This isn't too hard. Now open the properties and find the Row Source. This is where you have to type or create your query.

Copy the query I gave you, replacing the table and field names with the appropriate names.

Then tell me how it went.

Good luck!
(°v°)

Avatar of cisilay

ASKER

The first part (for combo box) is OK.
But I don't know where to enter AfterUpdate event. That's why the auto complete doesn't work.
The auto complete will work as soon as you have created the combo box with the appropriate row source.

The after update event is just a final polishing: making sure that a new entry is available directly in the next record. Without it, you need to close and re-open the form to see a new item in the list.

Does it work so far? Does your combo show all entries already in the table?

Anyway, to create the after update event:
* open the property sheet for your combo
* find the "after update" property"
* select [Event Procedure]
* click the builder button, looking like this: [...]
* add the line of code inside of the generated Sub

Good luck!
(°v°)
Avatar of cisilay

ASKER

1. The combo box now is working. But when I enter a new name, I must close and reopen the form.
2. I cannot find the "after update" in the combo box property sheet. Like I said I have no idea about these functions and I have to learn but some of them are important for me to begin. This one is one of them.

After all thanks to you for your help.
Regards.
ASKER CERTIFIED SOLUTION
Avatar of Markus Fischer
Markus Fischer
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cisilay

ASKER

OK it's OK now.
Thanks a lot and regards.
Glad it worked. Can I ask why I deserved only a B?
(°v°)
Avatar of cisilay

ASKER

I think B is good enough, but if you give some pts to me, mine will be C.
I don't understand what you mean with "mine will be C".

You probably don't realize that the question has the same "cost" to you regardless of the grade, so this is not an issue. However, the points received do depend on the grade: it's a multiplier. In this case, I do resent your reaction: "I think B is good enough". The polite thing to do would be at least to explain yourself.

You might also want to read: http:/help.jsp#hi73

(°v°)