Solved

Combo Box Default Value MS Access 2003

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

864 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

21 Experts available now in Live!

Get 1:1 Help Now