Passing data between forms

M

Mike Morton

Hello

I've got an issue which I hope someone can help with.
I have an application with a lot of data, so it's shown on a nested form :
Form has data (user) and subform1
subform 1 has data (customer) and subform 2
subform 2 has data (project) and subform 3
subform 3 has data (activity)

However, not all the data can be shown on one 'screen', so only 'headline'
info is shown. When the user wishes to amend a category of data from one of
the forms, or create a new record therein, they click a button within the
subform to open another form with all the required data fields.

Herein lies the problem, if you're still with me.
If the user changes and saves data within a 'customer' form, closing the
form should ideally trigger a data refresh in the customer subform (and,
consequently, the following subforms).
Equally, creating a new customer record should reposition the data on the
main forms to this new record, ready for data entry on the subforms.

I can't get either process to happen. Any ideas on how to make this work
would be most appreciated, as I'm totally stuck and don't want to have to
rethink my entire strategy.

Thanks

Michael Morton
 
A

Albert D.Kallal

you don't explain how you currently handle the case of click on that "view
details" button and viewing a existing record, and that of adding a new
record?

Do you have two buttons on each sub-form...one called add, and another
called view? Or, do you use the new "details" form that you opened to add
the new record?

The above issue is going to be critical in how we solve the "adding" of a
new record.......

Or, do you add the new record while in that sub-form..and THEN want to press
a button to edit more details? (this would be easier to code).

So, you need to explain what you do in the above two different cases....

Also, in which of the sub-forms do you have a view details button (all of
them?? --- or just one of them).
Equally, creating a new customer record should reposition the data on the
main forms to this new record, ready for data entry on the subforms.

So, does the above mean that all of the forms, including the main form, and
the sub-forms all have a edit details button too?

It is not clear at what point you add a new customer (main) record here? Is
there a add new button, or do you just use the navigation buttons to move
to a new record?

Hum, lets just deal with the sub-forms examples until the above is cleared
up. The easy way would be to simply on the close event of the form
do a refresh on the subform

forms!MyMainForm.MySubForm.Form.refresh

or...if two deep....

forms!MyMainForm.MySubForm.Form.mysubsubForm.Form.refresh
 
M

Mike Morton

Hello

I do indeed have two buttons, one for 'add' and one for 'amend'.
Both open a 'maintenance' form, in add only and edit modes respectively,
using the openargs property within the form where necessary.

My main problem seems now to be this : When the application follows this
routine
1. 'Main' opens (incl subforms)
2. User clicks button.
3. Maintenance form opens
4. Data is entered and saved
5. Maintenance form closes

I expected Main form events to trigger, even if only GotFocus or Activate.
In fact, neither event triggers. I've placed msgbox commands at the start
of each procedure in every form to test this ; after the maintenance form
closes, nothing fires until I click something. Surely the closing of one
form would mean that the focus should return to the previous form ? If
not... well, I'm stuck

This is really getting me down now. Any ideas where I'm messing up ?

Michael Morton
 
A

Albert D.Kallal

after the maintenance form closes, nothing fires until I click something.

The forms activate event will occur. So, you can put that example code of
mine in the active event to re-fresh the form.

However, if you add a new record, a refresh will not load/show new records.
You will have to do a requery

(me.requery...or....forms!formname!SubFormName.requery)

As mentioned, you can use the forms activate event, or use the forms "close"
event of the 2nd form that was opened....
 
M

Mike Morton

Albert

Thanks for that, I've sort of got it cleared up now. I've got to admit that
I find the order of event firing a bit strange (to say the least), but
passing some parameters between forms has given me something to check on
during the activate event.

Cheers

Michael Morton
 

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