running subs on other forms

Smee

Registered User.
Local time
Today, 20:18
Joined
Dec 16, 2003
Messages
69
Hey guys

Looked around for a solution to this one, but can't find one.

On a form we have a button that when pressed opens another form, fills in values on the new form. Now we want to press that forms 'OK' button but as it isn't a sub of the original we are struggling to find the right syntax.

We've made sure it is a public sub as well.

Any help greatly appreciated.

Thanks
 
A public sub should go in a standalone module; not in the module of a form.
 
In that case, maybe it shouldn't be public.

A bit more background then:

orderForm is a form that the user types in a few details, puts a few numbers into some boxes and then they click OK.

When they click OK, the form data is given an identifying number and put into a table for use later on.

A spreadsheet is opened and the user input data put into specific cells on the spreadsheet.

The spreadsheet is then saved, printed and closed so the user actually never notices that Excel has been opened.

summaryForm displays the details from the table where it was stored earlier. The summaryForm displays all orders for a certain jobno. Everytime the orderForm ok button is pressed the summaryForm will add a new record showing the latest order.

Next to each summary is a printButton.

When the printButton is pressed it needs to do everything as if the OK button on orderForm was pressed apart from adding the data into the table again, otherwise we'll get duplicates.

We figured, save writing the several hundred lines of code (with slight variances to control names make copy and paste not feasible) again, we can just open orderForm from summaryForm, fill in the user boxes with the table data and then press the OK button as if the form was being used by a normal user.

We've done everything apart from get summaryForm to press the OK button on orderForm and that's what we need to do. The reason for the above post was to run the code on the OK button, but pressing the button will achieve the same thing.

The only example we found was :

me.frmSubform.frmForm.doThisSub

but orderForm isn't a sub of summaryForm.

Is it possible?
 

Users who are viewing this thread

Back
Top Bottom