Solved

Combo Box Default Value MS Access 2003

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

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…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

832 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