Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default a Combo Box

Status
Not open for further replies.

mlocurci

MIS
Oct 17, 2001
210
US
I have a form that is an application form, I want to default some falues of the form (I dont want to do this at the table level), I should know this, but how do I default hte drop down? Which control do I need to touch? Each Drop Down has a yes, no, and NA choice, but it writes a value to the table (5,-5,0)
 
You have a couple of ways:

1.) Set the Default Value field in the combo box properties
2.) In VBA, you can do something like this:

Code:
Private Sub Form_Load()
  Combo1 = "Yes"
  Combo2 = "No"
  Combo3 = "NA"
  'And so on
End Sub

This is not intended to be the whole Sub-Procedure, but just demonstrates the idea. You would probably want to add an error handler.
 
I tried #1 above multiple times, but it never works. Any tips on how the default property works?
 
What did you try to set the default value to? What, specifically did you put in the option for the control?

Did you put No or
"No"
or a number? or
a table/query reference?
 
I put in the Row SourceL "Yes";1;"No";-1;"N/A";0
For Default Value I tried Yes and "Yes" as well as 1, -1, 0
 
Hmm... do you get an error message, or does it just not display on the form with the default value?
 
Another idea: Do you have a Contro Source for that control? If so, try taking that out and see... then if still doesn't work, take out the row source, and see if any different..
 
Yes, I do have a control source that stores column 2 (Bound Column=2).

No error, just the the box is not defaulted. I have another application where the object hsa the same setup, and it defaults to yes. I compared everything, an there is no difference.
 
Hmm, there's got to be some minor difference somewhere. Did you try taking out the control source, just to see.
 
Taking out the control source didn't seem to do much. This was odd. When I made the Default value yes, it defaulted to No. When I made it No, it defaulted to N/A. When I made it N/A, it added "" and didn't pick up any default.
 
Well, maybe the database is just possessed! :)

No, I'm sure there's an explanation somewhere...

Do you have ANY code for your form whatsoever? Anything, especially for the Form_Load or Form_Open events?
 
I know the term is frequent, but it might be corruption, ive had hunted forms in the properties before, Mlocurci, try to see if they randomly change... if they do, it is most likely corruption...
 
I been working on rebuilding the table, and it seems better now. I am now trying to default a field to the logged in user's name.....any ideas there :)
 
You could use the environment currentUser() .... or if you want to associate it to a full name or password, place it in a table, and have sections where you have pw etc....

but the currentuser() is probably what you are looking for.
 
i've never been able to get Default Value to work on combos...

Environ ("UeerName") is the way to go to get active user's name
 
How are ya mlocurci . . .

If your setting the default in code:
Code:
[blue]   Me![purple][b]ComboboxName[/b][/purple].DefaultValue = """No"""[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top