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

Form Procedure Question 2

Status
Not open for further replies.

quest4

Technical User
Aug 27, 2001
735
0
0
US
In a procedure, is it possible to set a combo box to a default item 0? If so how? The property sheet default value can not be used for this. Thanks to anyone who responses.
 
Try to put the following in the default value of the combobox to:

=MyCombobox.ItemData(0) Terry M. Hoey
 
Woops... Read, Terry, Read... I guess that won't help you. Sorry... Terry M. Hoey
 
You are right, I need to set this in a prcedure. Thanks for the response.
 
Okay, is the BoundColumn property set? if not, you can set that to 0 and then do:

MyForm!cboMyCombobox = 0

??? Terry M. Hoey
 
Actually, you can use the default value property, but you must use a fully declared reference:

=Forms![myFormName]![myComboControlName].ItemData(0)

Jim.
 
Thanks for responding. But no I can't use the Default Value, because I want it to remain blank most of the time. I do have an After Update procedure:
Private Sub WorkDay1_AfterUpdate()
DoCmd.GoToControl "WorkDay1Reason"
End Sub

I was hope to get it to run here, because this is the only time that I will need it. I guess you need to see the form "running" to understand it. Basicaly when I make a change to WorkDay1, which is a text box, I want to go to WorkDay1Reason, which is a combo box. I would like the default like this, because these are the two most likely settings:
If WorkDay1 = 0 Then
WorkDay1Reason.ItemData(0)
Else
WorkDay1Reason.ItemData(6)

I have tried all afternoon to get the if into the above procedure, but so far nothing but error, error, error everywhere. I have looked in every help thing I can find, but nothing is helping. Thanks again for the response.
 
Should be:

If Me![WorkDay1] = 0 Then
Me![WorkDay1Reason] = Me![WorkDay1Reason].ItemData(0)
Else
Me![WorkDay1Reason] = Me![WorkDay1Reason].ItemData(6)
End If

Jim.
 
I don't think it like that. I get the following error message:
"The expression On Current you entered as the event property setting produced the followinf error:Ambiguous name detected:WorkDay1_AfterUpdate."
Now I do have a procedure in Form_Current which is simply:
Private Sub Form_Current()

WorkDay1.SetFocus

End Sub
I don't see how that could effect it. Any thoughts? Thanks for the quick response.
 
I found it and now it is working. I had somehow pasted that first line on something much further down the list and way out of site. Thanks for all of the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top