More Form/SubForm Issues

  • Thread starter Thread starter TeeSee
  • Start date Start date
T

TeeSee

Help required as usual. The Cmd button sits on a [mainform] while the
SISitemCode resides on a subform on the [mainform]. The [MainForm]
opens but is blank. I think I'm missing some path to the subForm

Private Sub cmdCloneItem_Click()
DoCmd.OpenForm "frmMaterialMasterADD", , , "[SISitemCode] = " & Chr
$(34) & SISItemCode & Chr$(34)
End Sub

Any assistance would be appreciated.
 
in message
Help required as usual. The Cmd button sits on a [mainform] while the
SISitemCode resides on a subform on the [mainform]. The [MainForm]
opens but is blank. I think I'm missing some path to the subForm

Private Sub cmdCloneItem_Click()
DoCmd.OpenForm "frmMaterialMasterADD", , , "[SISitemCode] = " & Chr
$(34) & SISItemCode & Chr$(34)
End Sub

Any assistance would be appreciated.


So you're trying to refer to the SISItemCode field on the subform? To do
that, you need to include the subform itself in the reference -- that is,
the name of the subform *control* on the main form that acts as a window for
the subform. The name of the subform control may or may not be the name of
the form object it displays; yuo have to check that.

If the subform control were named "Subform1", then your code to refer to the
control on the subform would be:

DoCmd.OpenForm "frmMaterialMasterADD", , , _
"[SISitemCode] = " & Chr$(34) & Me!Subform1!SISItemCode & Chr$(34)
 
Note that in the newer versions of Access, you need to use
the Form property on your way to a control/property in a
subform:

... = " & Chr$(34) & Me!Subform1.FORM!SISItemCode & ...
 
Marshall Barton said:
Note that in the newer versions of Access, you need to use
the Form property on your way to a control/property in a
subform:

... = " & Chr$(34) & Me!Subform1.FORM!SISItemCode & ...


What version, Marsh? I've heard that said, but I haven't found that to be
the case with Access 2002 or 2003. Are there special circumstances in which
the simple SubformControlName!ControlName syntax doesn't work?
 
What version, Marsh?  I've heard that said, but I haven't found that tobe
the case with Access 2002 or 2003.  Are there special circumstances in which
the simple SubformControlName!ControlName syntax doesn't work?

For the record I am using Access 2003 and both of your suggestions
work equally well. Thank you for your responses

Strangely enough it also can be accomplished by the following
code ....

DoCmd.OpenForm "frmMaterialMasterADD", , , "[SISitemCode]='" & Forms!
[frmMainList]![SfrmItemsListSUB]![SISItemCode] & "'"

To be very honest I don't really understand that one but saw it posted
on one of the MANY subform questions.

Thanks again!
 
Dirk said:
What version, Marsh? I've heard that said, but I haven't found that to be
the case with Access 2002 or 2003. Are there special circumstances in which
the simple SubformControlName!ControlName syntax doesn't work?


That's odd, I ran into it all over the place until I learned
to always use .Form

I just ran a simple test in A2003 and got the expected
property or method not found message.

I have no idea why you would not see it. Perhaps it has
something to do with a converted vs new db or file format or
???
 
Marshall Barton said:
That's odd, I ran into it all over the place until I learned
to always use .Form

I just ran a simple test in A2003 and got the expected
property or method not found message.

I have no idea why you would not see it. Perhaps it has
something to do with a converted vs new db or file format or
???


I don't know. I ran a simple test in A2003 just to confirm, and the old,
simple notation worked fine. But I've heard other people talk about this,
so I know you aren't just making it up. Would you be willing to send me a
sample DB so I can see what the difference is?
 
Dirk said:
"Marshall Barton" wrote


I don't know. I ran a simple test in A2003 just to confirm, and the old,
simple notation worked fine. But I've heard other people talk about this,
so I know you aren't just making it up. Would you be willing to send me a
sample DB so I can see what the difference is?


I put together a simple test, zipped and sent it this
morning. Let me know if you don't get it.
 
Marshall Barton said:
I put together a simple test, zipped and sent it this
morning. Let me know if you don't get it.


I haven't received it yet. Did you remove "NO SPAM" and ".invalid" from my
e-mail address? Of course, you can always get my e-mail address from my
website. I'll try replying to your e-mail address as listed above, but I
expect that's a spam trap.
 
Dirk said:
I haven't received it yet. Did you remove "NO SPAM" and ".invalid" from my
e-mail address? Of course, you can always get my e-mail address from my
website. I'll try replying to your e-mail address as listed above, but I
expect that's a spam trap.


Yes, I have your correct email adddress.

My address is not a spam trap and, yes, I get a lot of spam,
but my ISP is fairly aggresive about filtering it out so
it's managable.

I got your email and included another copy of the file in my
reply.
 
Marshall said:
Note that in the newer versions of Access, you need to use
the Form property on your way to a control/property in a
subform:

... = " & Chr$(34) & Me!Subform1.FORM!SISItemCode & ...


I need to retract this note. I misread the reference as
using:
... = " & Chr$(34) & Me!Subform1.SISItemCode & ...
with a dot unstead of a bang (which does require the Form
property).

Don't ask me to explain why, but using bang:
... = " & Chr$(34) & Me!Subform1!SISItemCode & ...
does not need the Form property.

Whether or not it is a good practice to always use the Form
property when going through a subform control is a
discussion for another day.
 
Back
Top