after update doesn't update secondary field

E

efandango

I have a combo box that when Afterupdate is actioned, updates two fields
using the code below. This all works fine; but if I change the master data
elsewhere the only field that updates is the combo itself, but I want the
other two fields too update as well just like it does the first time when I
manuall use the combo box.

The fields [StreetNameID] and [Run_waypoint_ID] are properly linked using
cascade update. I tried using the code on the 'On Change' property, but this
didn't work either. What am I doing wrong?


Me.txt_Run_waypoint = DLookup("[StreetName]", "tbl_Street_Names",
"[StreetNameID] =" & txt_Run_waypoint_ID.Column(0))

Me.txt_Postcode = DLookup("[Postcode]", "tbl_Street_Names", "[StreetNameID]
=" & txt_Run_waypoint_ID.Column(0))
 
D

Douglas J. Steele

You're not doing anything wrong. The AfterUpdate event only fires when the
user selects a record in the combo. Changing it programmatically doesn't
fire the event.

However, you can always call the AfterUpdate yourself where you need to:

Call NameOfComboBox_AfterUpdate
 
E

efandango

Douglas,

How about if i use the On Change property?; I have tried to use this
property with the mentioned code, but it still doesn't go through the code
loop and update the other two properties. Does this property behave in a
similar way to AfterUpdate, in so much as the user has to manually select the
data. I am effecting this change via another form. I know I can do this via a
query, but i was hoping that the cascade update would 'kick-in' once the data
had changed in the main combo box.



Douglas J. Steele said:
You're not doing anything wrong. The AfterUpdate event only fires when the
user selects a record in the combo. Changing it programmatically doesn't
fire the event.

However, you can always call the AfterUpdate yourself where you need to:

Call NameOfComboBox_AfterUpdate

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


efandango said:
I have a combo box that when Afterupdate is actioned, updates two fields
using the code below. This all works fine; but if I change the master data
elsewhere the only field that updates is the combo itself, but I want the
other two fields too update as well just like it does the first time when
I
manuall use the combo box.

The fields [StreetNameID] and [Run_waypoint_ID] are properly linked using
cascade update. I tried using the code on the 'On Change' property, but
this
didn't work either. What am I doing wrong?


Me.txt_Run_waypoint = DLookup("[StreetName]", "tbl_Street_Names",
"[StreetNameID] =" & txt_Run_waypoint_ID.Column(0))

Me.txt_Postcode = DLookup("[Postcode]", "tbl_Street_Names",
"[StreetNameID]
=" & txt_Run_waypoint_ID.Column(0))
 
D

Douglas J. Steele

Change won't work any differently. If you want the code to run, you'll have
to call it yourself.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


efandango said:
Douglas,

How about if i use the On Change property?; I have tried to use this
property with the mentioned code, but it still doesn't go through the code
loop and update the other two properties. Does this property behave in a
similar way to AfterUpdate, in so much as the user has to manually select
the
data. I am effecting this change via another form. I know I can do this
via a
query, but i was hoping that the cascade update would 'kick-in' once the
data
had changed in the main combo box.



Douglas J. Steele said:
You're not doing anything wrong. The AfterUpdate event only fires when
the
user selects a record in the combo. Changing it programmatically doesn't
fire the event.

However, you can always call the AfterUpdate yourself where you need to:

Call NameOfComboBox_AfterUpdate

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


efandango said:
I have a combo box that when Afterupdate is actioned, updates two fields
using the code below. This all works fine; but if I change the master
data
elsewhere the only field that updates is the combo itself, but I want
the
other two fields too update as well just like it does the first time
when
I
manuall use the combo box.

The fields [StreetNameID] and [Run_waypoint_ID] are properly linked
using
cascade update. I tried using the code on the 'On Change' property, but
this
didn't work either. What am I doing wrong?


Me.txt_Run_waypoint = DLookup("[StreetName]", "tbl_Street_Names",
"[StreetNameID] =" & txt_Run_waypoint_ID.Column(0))

Me.txt_Postcode = DLookup("[Postcode]", "tbl_Street_Names",
"[StreetNameID]
=" & txt_Run_waypoint_ID.Column(0))
 
E

efandango

OK Douglas, I think I have learned something here...

so referential integrity rules only work if you manually change/update a
combo box; otherwise one would have to use a query, right?

I assumed that if I changed a 'master record' relating to a record source in
another table, that wherever it appeared, it would become the new data; but
now I understand that is not so, unless I use queries (which I can) to do the
updating.




Douglas J. Steele said:
Change won't work any differently. If you want the code to run, you'll have
to call it yourself.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


efandango said:
Douglas,

How about if i use the On Change property?; I have tried to use this
property with the mentioned code, but it still doesn't go through the code
loop and update the other two properties. Does this property behave in a
similar way to AfterUpdate, in so much as the user has to manually select
the
data. I am effecting this change via another form. I know I can do this
via a
query, but i was hoping that the cascade update would 'kick-in' once the
data
had changed in the main combo box.



Douglas J. Steele said:
You're not doing anything wrong. The AfterUpdate event only fires when
the
user selects a record in the combo. Changing it programmatically doesn't
fire the event.

However, you can always call the AfterUpdate yourself where you need to:

Call NameOfComboBox_AfterUpdate

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


I have a combo box that when Afterupdate is actioned, updates two fields
using the code below. This all works fine; but if I change the master
data
elsewhere the only field that updates is the combo itself, but I want
the
other two fields too update as well just like it does the first time
when
I
manuall use the combo box.

The fields [StreetNameID] and [Run_waypoint_ID] are properly linked
using
cascade update. I tried using the code on the 'On Change' property, but
this
didn't work either. What am I doing wrong?


Me.txt_Run_waypoint = DLookup("[StreetName]", "tbl_Street_Names",
"[StreetNameID] =" & txt_Run_waypoint_ID.Column(0))

Me.txt_Postcode = DLookup("[Postcode]", "tbl_Street_Names",
"[StreetNameID]
=" & txt_Run_waypoint_ID.Column(0))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top