subform not found on mainform

W

W

Hi,

I have an unbound form “frmMainFormâ€in which I have a bound subform
“frmSubFormâ€. I have a string strSQL which I use for the recordsource of
“frmSubForm†:

Set rst = db.OpenRecordset(strSQL)

I do not seem to be able to execute this command :
When I’m in the code of the main form, I have this line :

Me![frmSubForm].Form.RecordSource = strSQL

I get error 2465 : Access does not find frmSubForm.

Any help will be appreciated.

Thank you,

W
 
J

Jeanette Cunningham

Hi,
try it like this
Private sub MyRoutine()
Dim strSQL as String

strSQL = "code or name of the query here"
Me![Name of subform control].Form.RecordSource = strSQL
debug.print strSQL

End Sub
 
W

W

Hi Jeanette,

This is exactly what I do, and it does not work. So, my question still
remains open. Thanks for your suggestion anyhow.

W

Jeanette Cunningham said:
Hi,
try it like this
Private sub MyRoutine()
Dim strSQL as String

strSQL = "code or name of the query here"
Me![Name of subform control].Form.RecordSource = strSQL
debug.print strSQL

End Sub


W said:
Hi,

I have an unbound form "frmMainForm"in which I have a bound subform
"frmSubForm". I have a string strSQL which I use for the recordsource of
"frmSubForm" :

Set rst = db.OpenRecordset(strSQL)

I do not seem to be able to execute this command :
When I'm in the code of the main form, I have this line :

Me![frmSubForm].Form.RecordSource = strSQL

I get error 2465 : Access does not find frmSubForm.

Any help will be appreciated.

Thank you,

W
 
W

W

What I forgot, Access does not find nor recognize the subform, the SQL-string
is valid.

W

Jeanette Cunningham said:
Hi,
try it like this
Private sub MyRoutine()
Dim strSQL as String

strSQL = "code or name of the query here"
Me![Name of subform control].Form.RecordSource = strSQL
debug.print strSQL

End Sub


W said:
Hi,

I have an unbound form "frmMainForm"in which I have a bound subform
"frmSubForm". I have a string strSQL which I use for the recordsource of
"frmSubForm" :

Set rst = db.OpenRecordset(strSQL)

I do not seem to be able to execute this command :
When I'm in the code of the main form, I have this line :

Me![frmSubForm].Form.RecordSource = strSQL

I get error 2465 : Access does not find frmSubForm.

Any help will be appreciated.

Thank you,

W
 
J

Jeanette Cunningham

Hi,
Perhaps some more details would help us.
Access version.
Is it Access with a Jet backend?
How many forms and subforms are nested?
Would post the exact wording of the error message?
What happens if you delete the subform, save the form, then go back and add
the subform.

Jeanette Cunningham
 
R

Rick Brandt

W said:
Hi Jeanette,

This is exactly what I do, and it does not work. So, my question
still remains open. Thanks for your suggestion anyhow.

Is "frmSubForm" the name of the subform control, the name of the form contained
within the subform control, or both?

The syntax requires the name of the control, not the form. In many cases the
subform control and the form within have the same name in which case it wouldn't
be an issue. However; there is nothing that requires that they have the same
name and in those cases you need to use the name of the control.

You can see the name of the control by clicking (once) on its very edge while in
design view of the parent form. If you click twice or click inside the
perimeter you will be seeing the properties of the underlying form rather than
the properties of the control.
 
J

John Griffiths

Check to see if the drag amd drop operation added a numeral to the form name
to generate the control's name.

such as :-
Me![frmSubForm1].Form.RecordSource = strSQL
 
B

boblarson

Rick's advice is the part I would go with. That is the problem 99% of the
time when it comes to errors around subforms.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________


W said:
What I forgot, Access does not find nor recognize the subform, the SQL-string
is valid.

W

Jeanette Cunningham said:
Hi,
try it like this
Private sub MyRoutine()
Dim strSQL as String

strSQL = "code or name of the query here"
Me![Name of subform control].Form.RecordSource = strSQL
debug.print strSQL

End Sub


W said:
Hi,

I have an unbound form "frmMainForm"in which I have a bound subform
"frmSubForm". I have a string strSQL which I use for the recordsource of
"frmSubForm" :

Set rst = db.OpenRecordset(strSQL)

I do not seem to be able to execute this command :
When I'm in the code of the main form, I have this line :

Me![frmSubForm].Form.RecordSource = strSQL

I get error 2465 : Access does not find frmSubForm.

Any help will be appreciated.

Thank you,

W
 
W

W

Dear Jeanette,

Thanks for your answer, but Rick did already answer my question. Thanks to
have made an effort though.

W

Jeanette Cunningham said:
Hi,
Perhaps some more details would help us.
Access version.
Is it Access with a Jet backend?
How many forms and subforms are nested?
Would post the exact wording of the error message?
What happens if you delete the subform, save the form, then go back and add
the subform.

Jeanette Cunningham



W said:
Hi,

I have an unbound form "frmMainForm"in which I have a bound subform
"frmSubForm". I have a string strSQL which I use for the recordsource of
"frmSubForm" :

Set rst = db.OpenRecordset(strSQL)

I do not seem to be able to execute this command :
When I'm in the code of the main form, I have this line :

Me![frmSubForm].Form.RecordSource = strSQL

I get error 2465 : Access does not find frmSubForm.

Any help will be appreciated.

Thank you,

W
 

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