Running a nested sub form's code

User avatar
Peter Kinross
5StarLounger
Posts: 962
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Running a nested sub form's code

Post by Peter Kinross »

How do I run code from a sub form within a sub form from another module?
I tried:
Run Forms![frmClientsPolicies]![frmsubPoliciesForThisClient]![Policy Details].txtFunds_DblClick
but got an error
Avagr8day, regards, Peter

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Running a nested sub form's code

Post by HansV »

Have you made txtFunds_DblClick a Public procedure? By default, event procedures are always Private. So:

Public Sub txtFunds_DblClick(Cancel As Integer)
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Running a nested sub form's code

Post by HansV »

Oh, and call it like this:

Dim intCancel As Integer
Call Forms![frmClientsPolicies]![frmsubPoliciesForThisClient]![Policy Details].txtFunds_DblClick(intCancel)

Not Run!
Best wishes,
Hans

User avatar
Peter Kinross
5StarLounger
Posts: 962
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Re: Running a nested sub form's code

Post by Peter Kinross »

Made the sub a Public one.
dimmed intCancel As Integer
But I get a compile error on the Call line. Tried brackets before Forms! and at end, but still error.
Avagr8day, regards, Peter

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Running a nested sub form's code

Post by HansV »

Let me see - I'll have to experiment.
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Running a nested sub form's code

Post by HansV »

I'll be away from my computer for several hours. I'll look at your problem when I get back.
Best wishes,
Hans

User avatar
Peter Kinross
5StarLounger
Posts: 962
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Re: Running a nested sub form's code

Post by Peter Kinross »

If I remove the 'Call', the procedure compiles. But when it runs I get an error at that line:
"Object doesn't support this property or method"
Avagr8day, regards, Peter

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Running a nested sub form's code

Post by HansV »

Try this version:

Code: Select all

    Dim intCancel As Integer
    Forms!frmClientsPolicies!frmsubPoliciesForThisClient![Policy Details].Form.txtFunds_DblClick intCancel
Best wishes,
Hans

User avatar
Peter Kinross
5StarLounger
Posts: 962
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Re: Running a nested sub form's code

Post by Peter Kinross »

Yep, that worked!
ThanksHansStamp.gif
My stamp's ink is running out from over use.
You do not have the required permissions to view the files attached to this post.
Avagr8day, regards, Peter