Event order with subform and treeview control

G

Guest

Hi all

I wonder if someone can think of a solution here:

Using Access XP

I have a form containing a subform and a treeview control.

I have code to respond to the tvcontrol NodeClick event by displaying the
data relevant to the node in the subform.

I also have code responding to the OnExit events of the subform's contols
(text & combo boxes) such that changes made are committed to the database.

Problem is: the tvcontrol's NodeClick event fires BEFORE the OnExit event
when a new node is clicked while the cursor is in one of the subform's
controls - which I didn't expect - hence the changes are made to the data
underlying the new node, insted of the intended one.

Ideas (including a fundamentally new approach)?

Thanks for any time you may spend thinking about this.

Ali
 
N

Naresh Nichani MVP

Hi:

Maybe in the NodeClick event you store the ID of the data you want to save
in a Private variable on Form. When user clicks a new Node and if this
Private variable at Form level is not 0 you save to that ID and then
activate new data based on Node?

Regards,

Naresh Nichani
Microsoft Access MVP
 
G

Guest

The use of subforms in a form cantaining Treeview control, at least up to
acc2000 prooved to be a constant generator of non typical errors (mostly
memory-related i think) when data was of a considerable quantity. The Access
crash message was my nightmare.
Anyway as Haresh says wisely, you should work with variables or (even
better?) with unbound controls on the main form in which you store the id
(Key values , text or whatever) of the node in the click event, thus
providing an additional time for access(it works asychronous) to respond in
events. This is a practical aproach which saved me in several ocasions -dont
ask me why. Furhter more try to use the linkparent/linkchild fields of the
subform with this(or these) unbound control to auto sychronize the data in
subform with the selected click. When you save the data check if the id of
the data is the same in the unbound control or the variable. If yes proceed,
if no notify the user to decide what to do. For examle if the id is different
you could relocate the record (with code or with the use of a rs.bookmark)
and complete the saving job.
 

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