Using the same value in a field

Robbieb29

Registered User.
Local time
Today, 17:30
Joined
Nov 17, 2009
Messages
13
Hi

I have a database where the user enters the location from a combo box, but when the user goes to enter the next record the location is blank. How do I get the field to show the previous location until a new one is selected then that becomes the default.

Thanks Rob
 
Last edited:
You could use the following in the After Update event of Your Combo;
Code:
Me.ComboName.DefaultValue = Me.ComboName
 
Unfortunately this doesn't seem to work. Any other ideas
 
Unfortunately this doesn't seem to work. Any other ideas

When you say "this doesn't seem to work" what actually happens?

You did put the code provided in the VBA window of the event and NOT in the event PROPERTY in the form's dialog, correct?
 
I put the code in the combobox afterupdate section, but on running form view the field remains blank after entering the first location. I would like the value to remain in the combo box until the user changes the locatio. Thus reducing the amount of data to be entered by the user.

Thanks
 
That's not the way the defaults work. It will place that value there if you start a new record, but it won't just leave it there. If you start adding another field then the value should appear.
 
This is what I entered, but it didn't work

Private Sub LOCATION_AfterUpdate()
Me.LOCATION.DefaultValue = Me.LOCATION
End Sub

Any ideas
 
The correct syntax would be

Me.LOCATION.DefaultValue = """" & Me.LOCATION & """"

Just be aware that if you're using the AfterUpdate event of the combobox to perform a task, assigning the value to the combobox in this manner will not fire the AfterUpdate event.
 
The correct syntax would be

Me.LOCATION.DefaultValue = """" & Me.LOCATION & """"

Just be aware that if you're using the AfterUpdate event of the combobox to perform a task, assigning the value to the combobox in this manner will not fire the AfterUpdate event.

The code I provided works fine in my "Sand Box" DB.

Please note however that the default will only persist whilst the form remains open. If the form is closed the default that is set using this method will be lost when the form is closed, and must be reset the next time the from is opened, it will revert to the Default saved in the field data tab.
 
Tried this and it still does not work

Private Sub LOCATION_AfterUpdate()
Me.LOCATION.DefaultValue = """" & Me.LOCATION & """"
End Sub
 
Any chance you can post a copy of your DB? So we can have a look at what's (not) going on.
 
Given that that is 2008 format I'll not be able to have a look at it for another couple of hours, when I have access to a machine with that format on it. I'll let you now as soon as I get a chance.
 
I believe that the reason this code is not working is because you are using Table Level Lookups. Congratulations you have stumbled upon one of the reasons their use is discouraged.

See this thread for further discussion on the subject and how to fix your DB.
 
I have looked at both threads, and copied the text into my form, but still the fields are not continuing to display the text.

I have attached my Database, please tell me what im doing wrong
 

Attachments

Last edited:
Since I do not have Access 2007 here at work, I will have to take a look after I get home in about 10 hours. If anyone else has it and wants to look, feel free.
 
You've made no substantive changes to your DB. You need to move those Table Level look Ups into their own tables and then use Combo Boxes.

Go and re-read this thread particularly post #8 also follow the three links in that post. Once you have read and understood the concepts discussed there you should be able to move forward.
 

Users who are viewing this thread

Back
Top Bottom