What event to use to update other fields

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hi,

I have a combobox in a subform that has the onchange, onupdate and ondirty
events enabled. The code updates the content of other fields in the subform
when the combobox is updated. The problem is these events do not occur when
the contents of the combobox changes due to the another event.

For example

I want the textboxes txtName, txtaddress1 and txtaddress2 to be updated when
the content of cmbUserID changes. The code I'm using is for the change,
dirty and update events is:

myArray = Array("Name","Address1", "Address2")
sFormName = Forms("frmThirdPartyReturns")("sfrm46GDetails")

i = 0

For i = 0 To 2
varx(i) = DLookup(myArray(i), "tblThirdPartyData", "[ThirdPartyID] = " &
sFormName("cmbThirdPartyID"))
sFormName(myArray(i)) = varx(i)
Next i

This works fine when I directly change the content either by typing or
selecting a userid in the combo box. I have a number of navigation command
buttons on the form. When I click on of these e.g. Next or previous record,
the content of the combobox changes but the content of the other fields does
not.

How can I get the code to run no matter how the content of the combobox
changes

Any advise appreciated

Paul
 
Paul

If you have an AfterUpdate event running in the combo box, you can call that
event from other code.

Jeff Boyce
<Access MVP>
 
Thanks Jeff,

The only problem with that is I would have to call that event from every
control that results in a change in the content of the combobox e.g. if I
have a next and previous botton I would have to call the event from both of
these.

This wouldn't be the best solution as I have a number of control that could
result in the contents of the combovbox changing. This would be difficult to
manage if I had to make changes.

Is there any way I can accomplish this that all the code is contained within
just the combobox control

Regards

Paul

Jeff Boyce said:
Paul

If you have an AfterUpdate event running in the combo box, you can call
that
event from other code.

Jeff Boyce
<Access MVP>

Paul said:
Hi,

I have a combobox in a subform that has the onchange, onupdate and
ondirty
events enabled. The code updates the content of other fields in the subform
when the combobox is updated. The problem is these events do not occur when
the contents of the combobox changes due to the another event.

For example

I want the textboxes txtName, txtaddress1 and txtaddress2 to be updated when
the content of cmbUserID changes. The code I'm using is for the change,
dirty and update events is:

myArray = Array("Name","Address1", "Address2")
sFormName = Forms("frmThirdPartyReturns")("sfrm46GDetails")

i = 0

For i = 0 To 2
varx(i) = DLookup(myArray(i), "tblThirdPartyData", "[ThirdPartyID] = " &
sFormName("cmbThirdPartyID"))
sFormName(myArray(i)) = varx(i)
Next i

This works fine when I directly change the content either by typing or
selecting a userid in the combo box. I have a number of navigation
command
buttons on the form. When I click on of these e.g. Next or previous record,
the content of the combobox changes but the content of the other fields does
not.

How can I get the code to run no matter how the content of the combobox
changes

Any advise appreciated

Paul
 
Paul

If you are saying that other objects are doing things, and you want the
combo box's AfterUpdate code to fire when those things happen, then putting
the (other) code in the AfterUpdate event of the combo box won't get it
fired!

And if you are saying that you have two or so other controls that can affect
the contents of the combo box, how much work is it to include:

Call cboMyComboBox_AfterUpdate()

in an event (?Click) for those two?

Good luck

Jeff Boyce
<Access MVP>

Paul said:
Thanks Jeff,

The only problem with that is I would have to call that event from every
control that results in a change in the content of the combobox e.g. if I
have a next and previous botton I would have to call the event from both of
these.

This wouldn't be the best solution as I have a number of control that could
result in the contents of the combovbox changing. This would be difficult to
manage if I had to make changes.

Is there any way I can accomplish this that all the code is contained within
just the combobox control

Regards

Paul

Jeff Boyce said:
Paul

If you have an AfterUpdate event running in the combo box, you can call
that
event from other code.

Jeff Boyce
<Access MVP>

Paul said:
Hi,

I have a combobox in a subform that has the onchange, onupdate and
ondirty
events enabled. The code updates the content of other fields in the subform
when the combobox is updated. The problem is these events do not occur when
the contents of the combobox changes due to the another event.

For example

I want the textboxes txtName, txtaddress1 and txtaddress2 to be updated when
the content of cmbUserID changes. The code I'm using is for the change,
dirty and update events is:

myArray = Array("Name","Address1", "Address2")
sFormName = Forms("frmThirdPartyReturns")("sfrm46GDetails")

i = 0

For i = 0 To 2
varx(i) = DLookup(myArray(i), "tblThirdPartyData", "[ThirdPartyID] = " &
sFormName("cmbThirdPartyID"))
sFormName(myArray(i)) = varx(i)
Next i

This works fine when I directly change the content either by typing or
selecting a userid in the combo box. I have a number of navigation
command
buttons on the form. When I click on of these e.g. Next or previous record,
the content of the combobox changes but the content of the other fields does
not.

How can I get the code to run no matter how the content of the combobox
changes

Any advise appreciated

Paul
 
Back
Top