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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Set to Blank on Open

Status
Not open for further replies.

infact

Technical User
Jan 9, 2006
27
US
I am new to Access. How do I add Me.ComboBoxName = "" to on Open event for a form ? This is to set a combo box to blank when form opens. Thanks.
 
open the properties for the form.
go to the events tab
click on the three dotted button at the end of the event in question ...
put the code you have, in the proceedure.

or

if the combobox is based on a table, why not have the first record blank and set this as default.

save the code

remember to change the comboboxname to the actual name of the combo box

or

open the properties of the combobox itself and set its default value to "" or " "


Ian Mayor (UK)
Program Error
Programmers do it one finger at a time!
 
Thanks for this tip. I tried both of your suggestions, but am getting a "cannot assign a value to this item" error message when I run the form. The form is based on a query which pulls some records off of a data file, including the one ("shift") that I made a combo box. I suspect that it is something I am doing up front with the query which is not allowing me to set this field to default value of blank or to set it to blank using the ME.Combobox code in the form event.
 
How are ya infact . . .
infact said:
[blue]This is to set a combo box to blank when form opens.[/blue]
When opening a form, the textbox portion of a combobox is [blue]blank by default[/blue] . . . that is unless the [blue]DefaultValue[/blue] property of the combobox is set to some value, or you have code making a selection.

Unless you just want to know how to do this . . . am I missing something?



Calvin.gif
See Ya! . . . . . .
 
Thanks for replying, Aceman 1 -- The combo box is set up as a value list with two values, Day,Eve. Upon opening a form I thought a combo box was blank by default, but one of these values appears in the text box, and as above, when I tried to apply code to set it to blank or set the default to blank in properties, I get an error message that I cannot assign a value to the item. There is nothing in the default in properties.
 
infact . . .

Definitely [blue]something wrong here![/blue]

Delete & reinstantiate the combobox . . .

Calvin.gif
See Ya! . . . . . .
 
And what about using the Load event instead of the Open ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top