Calling a sub of the subform

  • Thread starter Thread starter JustinP
  • Start date Start date
J

JustinP

I'm try to call a sub in a subform from the mainform like this:

Forms![MainForm].Form![subform].Form![control in subform].name of sub

e.g. Forms![Property].Form![subfrmEase].Form![txtEase1].UpdateEnc

But it doesn't seem to work. Any ideas?
 
JustinP said:
I'm try to call a sub in a subform from the mainform like this:

Forms![MainForm].Form![subform].Form![control in subform].name of sub

e.g. Forms![Property].Form![subfrmEase].Form![txtEase1].UpdateEnc

But it doesn't seem to work. Any ideas?

Two things:

1. The Sub in question must be declared as Public. It defaults to
Private.

2. I don't see why you are introducing the control "txtEase1", which I
assume is a text box. All code in the subform belongs to the form
module itself, not to the control.

So make sure your sub is declared as Public; e.g.,

Public Sub UpdateEnc()

And call it like this:

Forms![Property].Form![subfrmEase].Form.UpdateEnc

Or, if you're making the call from the main form ("Property") itself,
like this:

Me!subfrmEase].Form.UpdateEnc

Incidentally, in case you haven't discovered it already, "Property" is
not a good name for any object. Because it's a reserved word, it can
easily be misinterpreted by Access, and you have to be careful how you
refer to any object with that name.
 

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

Similar Threads


Back
Top