RecordSource Property

  • Thread starter Thread starter NEWER USER
  • Start date Start date
N

NEWER USER

I am having some difficulty geeting the RecordSource property to work. I am
trying to use ONE form to display records differently rather than creating
separate forms and subforms. My form is titled frmGrouping and has its
RecordSource as qryGrouping. I want to change the RecordSource to
"qryProductGrpPads" when the form opens. The only difference in the two
queries is one table that I build prior to opening the form. I have the
following code attached to a Command button on a Form used to call the form.

On Error GoTo Err_Alternates_Click
Dim strDoc As String
Dim strDoc1 As String
Dim strDoc2 As String

strDoc = "qryMakeTableGrpPads"
strDoc1 = "frmGrouping"
strDoc2 = "qryProductGrpPads"

DoCmd.SetWarnings False
DoCmd.OpenQuery strDoc, acNormal, acEdit
DoCmd.OpenForm strDoc1, acNormal, "", "", , acNormal
Me.RecordSource = strDoc2
DoCmd.SetWarnings True

Exit_Alternates_Click:
Exit Sub

Err_Alternates_Click:
MsgBox Err.Description
Resume Exit_Alternates_Click

The form is opening BLANK; The RecordSource is not substituing in place of
the
one defined in the form properties. Any help appreciated.
 
Did you really intend the change the recordsource of the current form?
Or did you intend to change the RecordSource of frmGrouping?

If the latter, try:
Forms(strDoc1).RecordSource = strDoc2
 
I meant the latter and your suggestion nailed it. Thanks again for the help.
Truly appreciated.
 
Back
Top