changing record source for form with option button

  • Thread starter Thread starter Jerry Anderson
  • Start date Start date
J

Jerry Anderson

I have an option group with two buttons: Actual and Projected. Based on the
selection, the record source for a subform is changed as indicated by the
following code:

Private Sub CostType_AfterUpdate()

Select Case Me!CostType
Case 1
Forms.AdministratorInput.AdministratorSalaries.RecordSource =
ActualSalaries
Forms.AdministratorInput.AdministratorOther.RecordSource =
ActualOtherCosts
Case 2
Forms.AdministratorInput.AdministratorSalaries.RecordSource =
ProjectedSalaries
Forms.AdministratorInput.AdministratorOther.RecordSource =
ProjectedOtherCosts
End Select

End Sub
When it executes, I get an error message pointing to the name of the table
for the record source as not being defined. What am I doing wrong?
 
I have an option group with two buttons: Actual and Projected. Based on the
selection, the record source for a subform is changed as indicated by the
following code:

Private Sub CostType_AfterUpdate()

Select Case Me!CostType
Case 1
Forms.AdministratorInput.AdministratorSalaries.RecordSource =
ActualSalaries
Forms.AdministratorInput.AdministratorOther.RecordSource =
ActualOtherCosts
Case 2
Forms.AdministratorInput.AdministratorSalaries.RecordSource =
ProjectedSalaries
Forms.AdministratorInput.AdministratorOther.RecordSource =
ProjectedOtherCosts
End Select

End Sub
When it executes, I get an error message pointing to the name of the table
for the record source as not being defined. What am I doing wrong?

The RecordSource property must be a String. Put it in quotes:

Forms.AdministratorInput.AdministratorSalaries.RecordSource =
"ActualSalaries"
 
Thanks. It worked like a charm!

John W. Vinson said:
The RecordSource property must be a String. Put it in quotes:

Forms.AdministratorInput.AdministratorSalaries.RecordSource =
"ActualSalaries"
 
Back
Top