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!

Combo Box "Trigger Event" 1

Status
Not open for further replies.

kenman

Programmer
Dec 21, 2000
12
0
0
US
I have a Form that is showing a Table in Datasheet View that has 10 Fields. The 1st field is a Combo box. When a value is selected from this Combo Box, I default the remaining 9 fields to values related to the Combo Box Value using the "After Update" Event. This seems to work perfectly. This combo Box lists 1000 values, but there are 3 or 4 that are "Normal Selections". I have 4 buttons on my form so the user can automatically select a particular Combo Box Value from the List. When the button is pressed I set the [FieldName].Value = ButtonPressedValue. The Combo box field on the Datasheet reflects the new value, but the "After Update" Event does not fire off...as I have forced the value in and the Combo Box doesn't know it.

My question is - From my buttons, how do I trigger the Combo Box "After Update" Event after setting the Value?

I know in other languages there is a Combo Box Method that is used to "SelectRow(Index)" and then the Combo Box can't Tell if the user did it or some other fuction did it...but I don't see this in Access.

Thanks,
Ken
 
You're trying to make it too hard. Just call the ComboBox1_AfterUpdate procedure yourself. Rick Sprague
 
Rick,

The datasheet is actually a subform on a form. If I put the button in the subform and have

Call PartID_AfterUpdate it works ok.

I want to have the button on the Form, so I tried
Call [subfrmOrderDetails].PartID_AfterUpdate
and
Call form![subfrmOrderDetails].PartID_AfterUpdate
but I can't seem to get the syntax right.

Thanks in advance,

Ken
 
Ouch! You didn't mention the subform before. Unfortunately, I don't think you can call a procedure in a subform from the main form. At least I don't know any way.

BTW, one of the problems with your syntax is that "subfrmOrderDetails" refers to the subform control, not to the form displayed in the control. You can get to properties and control in the subform itself using the syntax:
[subfrmOrderDetails].Form.xxxx

However, methods (public procedures) in the subform can't be called this way, and I can't think of a way to get around this. The problem has something to do with the fact that, for a subform, the actual object variable that references the subform is owned by Access, and is not available to your code.

Sorry I can't be more help this time. Rick Sprague
 
Wouldn't the "Requery" command give the required result, or am I showing my own ignorance again??


Lightning
 
Is that what you have in the combo box's AfterUpdate event--Requery calls for each of the other 9 controls on the subform? If so, then yes, you can just call each of their Requery methods (using the subformcontrolname.Form!controlname.Requery syntax).

Or are you talking about requerying the combo box itself, to try to get AfterUpdate to run? I don't that will work, but it's worth a try.

If you don't get it working, paste in the code from the combo box's AfterUpdate procedure and maybe I can find a workaround. Rick Sprague
 
Rick,

The combobox has 5 fields in it with only the 1st field visible. When the user selects a combobox value normally (in the datasheet), I pick up the 4 invisible fields (using .column(1), .column(2), etc), manipulate them and place the 'manipulated' values in the remaining 9 fields in the datasheet. This manipulation is in the AfterUpdate event. When I have my 4 buttons "automatically" choose a value in my combobox, I wanted trigger the AfterUpdate event to run.... so that after setting the combobox value, I can pick up the invisible values, manipulate them, then throw the values in the other fields....unfortunatly I was unable to "triger" the subform event from my form. I know in Powerbuilder you can use a function called combobox.setitem(Value) and this will set the combobox value.....and Powerbuilder can't tell if it was the user or an external function....thus triggering all normal events....but I didn't see anything like this in the Access help.

As I was unable trigger an event in the subform from my form (as access can't seem to get a 'handle' on the subform...like you mentioned), I put the Manipulate logic under each button....so I have very similar logic in 2 places. I have no problem setting values in the datasheet from my form. I briefly played with making a generic function that both events could call, but ran into some syntax problems....so I gave up and went with the easy method.
I would still like to try to find out how to trigger an event in a subform from a main form, as I may bump into this again, but I feel I have found a workaround at this point.

Thanks for your help,

Ken
 
Glad you got something working. If you ever find out how to call a procedure (as opposed to a method) of a control on a subform, please post it here as a tip. I think it would be very useful! Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top