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!

ComboBox Default Value

Status
Not open for further replies.

timb94

Programmer
Apr 20, 2004
58
US
I have a subform (datasheet) that has a textbox to enter a date and a combobox. The combobox values are populated from a query and the results is stored into a sql database.

What I need to do is if an operator enters a date in the date field to populate the combobox with a default value from the query list.

In the textbox AfterUpdateEvent I placed the following code (the default code is the second record in the query):
Code:
Me.Inspection_Code.SetFocus
Me.Inspection_Code.ListIndex = 1

When I enter a date in the text field and tab off or go to the next record it errors out on the ListIndex = 1 line with the following message:
"The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing STARR from saving the data in the field."

I don't have any macro's or functions set up for this field so I don't know where it's getting it from.

The field in the sql table is 4 characters and none of the entries in the combobox are over 4 so I know it's not a truncation problem.

As a further test I set up another combobox and entered the values in rather than from a table thinking the query may be the problem but the same thing happened.

Any ideas or suggestions would be appreciated.
We are running Access 2007 and if you need further information, please let me know.
 
Thank you for your reply.
After sending my initial question I found a work around to it.

What I did was place the following statement in the afterupdateevent of the text box:

Me.Inspection_Code.Value = "EXTR"

Now when they enter a date in the text field it will automatically enter "EXTR" in the dropdown box. This code is in the second row of the dropdown. I still want to come up with a better solution but this will work for now.

Thank's again for your reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top