Solved

Combo Box Default Value MS Access 2003

Posted on 2009-07-04
5
301 Views
Last Modified: 2013-11-28
I have a combo box that looks up a value (date) using a query in the control source.  The query returns only one record which I wish to use as the default record that is written to the table allowing the user to override with a different date if needed.  The combo box is obviously bound to a field in a table.

I have tried all of the following in the default value property of the combo box.  None work.

=[cboName].[ItemData](0)
=[cboName]![ItemData](0)
=[cboName].[ListIndex](0)

This should not be difficult but all research turns up the same answers as above.  Help?
0
Comment
Question by:SusieCook
  • 3
  • 2
5 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 24779022
I would have expected
=[cboName].[ItemData](0)
to work.
I assume you aren't displaying fieldnames in the combo box? (you would used1 instead of 0 )

You can use code instead.
In the form_current event procedure do..

if me.newrecord then Me!cboName= Me!cboname.ItemData(0)
                        
0
 

Author Comment

by:SusieCook
ID: 24780073
I would expect the form_current event to work - however, let me get a little more detailed.
Thank you for your response.  The combo box is in a subform.  The subform is in a continuous format.  The combo box pulls it's list of values based on a value selection in the previous combo box on the same record.  The previous combo box has an after-update event to requery the combo box where I want the default....the query runs correctly, the data is correct, I just can't get the result from the query to be the default.

If I am to use code, it would need to be at the record level.  I really don't need a combo box - a text box with the default value would work as long as the default value from the query posts to the table and allows the user to modify/change the original entry.  Open to all suggestions.  File attached with sample.
ComboBoxDefaultIssue.doc
0
 

Author Comment

by:SusieCook
ID: 24780180
increasing point value - this may be a little more difficult than I anticipated.
0
 
LVL 77

Accepted Solution

by:
peter57r earned 250 total points
ID: 24780239
Default value is not going to do it then, because defaults are only applied as you move to a new record.
You need to add the command:
me.cboname  =[cboName].[ItemData](0)
to your afterupdate of the first combo after the requery.
It is just possible that you will hit timing issues with that so you should should probably add a Doevents command between the requery and the assignment.
0
 

Author Closing Comment

by:SusieCook
ID: 31599846
This works so far.  No timing issues.  I will test for the full record of all six dates.  Thank you!!!!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now