changing record source for form with option button

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?
 
J

John W. Vinson

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"
 
J

Jerry Anderson

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"
 

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