Changing a subform's recordsource

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I asked something similar to this a few days ago, but I am trying a different tack. Although the previous answer did help with another problem (Thank you Pat Hartman).

I am trying to change the subform's recordsource to either a query or select statement depending on how the primary form is opened. I am using:

Me!sfrmQUESTIONS.Form.RecordSource = qrypic_quest

And I get an error of "cannot find the field sfrmquestions referred to in your expression.

I also would mind being able to use something like the select statement in the VB help, but would it work on a subform.
 
In your statement - 'sfrmQuestions' should be the name of the subform
control on the main form. Double check the name by clicking once on the
subform then checking the name property.

The value of the RecordSource property must be a string so quotes are needed
around the name of the query as shown below.

Me!sfrmQUESTIONS.Form.RecordSource = "qrypic_quest"
 
I am still getting the same error, and I checked that the name of the subform is correct. Here is the total code, maybe I have something before it wrong.

Dim stDocName As String
Dim CURREVENT As String

CURREVENT = autEVENTID
stDocName = "sfrmANSWERS"
DoCmd.OpenForm stDocName, , , , , , CURREVENT

Me!sfrmQUESTIONS.Form.RecordSource = "qrypic_quest"

DoCmd.GoToRecord , , acNewRec

--
Ficticiously Yours, Biggles


Sandra Daigle said:
In your statement - 'sfrmQuestions' should be the name of the subform
control on the main form. Double check the name by clicking once on the
subform then checking the name property.

The value of the RecordSource property must be a string so quotes are needed
around the name of the query as shown below.

Me!sfrmQUESTIONS.Form.RecordSource = "qrypic_quest"

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I asked something similar to this a few days ago, but I am trying a
different tack. Although the previous answer did help with another
problem (Thank you Pat Hartman).

I am trying to change the subform's recordsource to either a query or
select statement depending on how the primary form is opened. I am
using:

Me!sfrmQUESTIONS.Form.RecordSource = qrypic_quest

And I get an error of "cannot find the field sfrmquestions referred
to in your expression.

I also would mind being able to use something like the select
statement in the VB help, but would it work on a subform.
 
Is sfrmQuestions on the form you are opening? If so you can't use the "Me"
keyword since it relates to the form running this code. Instead it would be:

forms!sfrmAnswers.sfrmQUESTIONS.Form.RecordSource = "qrypic_quest"


--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I am still getting the same error, and I checked that the name of the
subform is correct. Here is the total code, maybe I have something
before it wrong.

Dim stDocName As String
Dim CURREVENT As String

CURREVENT = autEVENTID
stDocName = "sfrmANSWERS"
DoCmd.OpenForm stDocName, , , , , , CURREVENT

Me!sfrmQUESTIONS.Form.RecordSource = "qrypic_quest"

DoCmd.GoToRecord , , acNewRec

In your statement - 'sfrmQuestions' should be the name of the subform
control on the main form. Double check the name by clicking once on
the subform then checking the name property.

The value of the RecordSource property must be a string so quotes
are needed around the name of the query as shown below.

Me!sfrmQUESTIONS.Form.RecordSource = "qrypic_quest"

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I asked something similar to this a few days ago, but I am trying a
different tack. Although the previous answer did help with another
problem (Thank you Pat Hartman).

I am trying to change the subform's recordsource to either a query
or select statement depending on how the primary form is opened. I
am using:

Me!sfrmQUESTIONS.Form.RecordSource = qrypic_quest

And I get an error of "cannot find the field sfrmquestions referred
to in your expression.

I also would mind being able to use something like the select
statement in the VB help, but would it work on a subform.
 
Back
Top