Need help with Subform problems

G

Guest

Hi All,

I am having a problem with a subform on a tab on a Main Form.

I cannot get any expressions or VBA of either the subform or the subform
controls to work.

I have searched and found no answer.

These did not work:

Forms![myMainFormName]![mySubFormName].Form![MyctlName]
Me![mySubFormName].[MyctlName]
Me![MyctlName]
Me.[MyctlName]
Me.MyctlName
Me!MyctlName
[mySubFormName]
[myMainFormName].[mySubFormName]
Forms![myMainFormName].[mySubFormName] etc., etc.

I have checked my spelling, my SourceObject, etc. I have references to OLE
Automation, DAO 3.6 Objects Library, ActiveX Data Objects 2.8 Library and
more.

I tried to use work around and use a calendar control to set a date in a
textbox, but I kept getting a error message.


Private Sub btnMarriageDate_Click()
Dim myNewDate As Long
Call myNewDatePicker(myNewDate)
Me!MarriageDate = myNewDate
End Sub


Public Function myNewDatePicker(myNewDate As Long)
Dim CalendarControl2 As Calendar
DoCmd.OpenForm "frmCalPick2" ' This form has the Calendar control
myNewDate = CalendarControl2.Value
End Function

My Function returns this error:
Error 91 Object Variable with Block Variable not set

I think I may be getting this error because I am not using my form name in
the Function, but that is the problem--I can't use the subformname and get it
to work with anything.


I would appreciate any help
Hunter57
 
J

John W. Vinson

Forms![myMainFormName]![mySubFormName].Form![MyctlName]

This is the correct syntax - *BUT* for mySubFormName you must use the Name
property *of the Subform control*. That is sometimes the same as the name of
the source object, the form within that control, but not necessarily!


John W. Vinson [MVP]
 
H

Hunter57

Forms![myMainFormName]![mySubFormName].Form![MyctlName]

This is the correct syntax - *BUT* for mySubFormName you must use the Name
property *of the Subform control*. That is sometimes the same as the name of
the source object, the form within that control, but not necessarily!

John W. Vinson [MVP]

Hi John,


In my Properties Sheet here is what I have:

Other tab:
Name subfrmPeopleMembers

Data tab:
Source Object subfrmPeopleMembers

No matter where I look I can see no other name.

Hunter57
 
J

John W. Vinson

In my Properties Sheet here is what I have:

Other tab:
Name subfrmPeopleMembers

Data tab:
Source Object subfrmPeopleMembers

No matter where I look I can see no other name.

Hrm. That rules out THAT problem...

Your form may be corrupt. Try creating a new form; copy and paste the objects
from this one onto it. I'd suggest creating the new subform from scratch (by
dragging subfrmPeopleMembers onto the form and manually setting the
master/child link fields).

John W. Vinson [MVP]
 

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