Remember last entries in a forms text box or combo box

F

Fletcher

I would like a text box (and a combo box) on a form to remember the
last entry, but still be able to be changed if necessary. Can someone
point me towards a method of doing this?

I thought I've seen this topic before, but can't seem to find it
anywhere after searching and reading for nearly an hour.

Thanks in advance,

Fletcher
 
S

Steve

Put the following code in the AfterUpdate event of your control:
Me!NameOfYourControl.DefaultValue = Me!NameOfYourControl

The control will "remember" the last entry for as long as the form is open
but "memory" will be lost when the form is closed.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
A

Al Campagna

Fletcher,
I think what you're referring to is the ability to make a bound control
assume a DefaultValue during an entry/editing "session".
Let's say you have a field called City, and the next 20 records you want
to add are all "Boston" for the City value.
Use the AfterUpdate event of City to set a DefaultValue for City. (Enter
Boston as the City)

Private Sub City_AfterUpdate()
Me.City.DefaultValue = "'" & City & "'"
End If

Every New record you add during that session will have a City
DefaultValue of "Boston"...
UNTIL... you change it to something else.
After 20 Boston records, you enter a "New York" record... now... "New
York" becomes the DefaultValue, and any new records, from then on, will have
a City value of "New York"

This is only in effect for the current "session" of that form.
--
hth
Al Campagna
Access MVP 2007
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love, and you'll never work a day in your life."
 
A

Al Campagna

Fletcher,
For clarity, I'll expand the quotes in the code I suggested, so you can
it more clearly.
Do not use the spaces in the real code...
Me.City.DefaultValue = " ' " & City & " ' "
--
hth
Al Campagna
Access MVP 2007
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love, and you'll never work a day in your life."
 
S

Steve

Sorry, I forgot to add the quotes ---
Me!NameOfYourControl.DefaultValue = "'" & Me!NameOfYourControl & "'"

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 

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