Solved

Combo Box Default Value MS Access 2003

Posted on 2009-07-04
5
305 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

809 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