Solved

Combo Box Default Value MS Access 2003

Posted on 2009-07-04
5
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

630 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