Different tables as combobox RowSource in a form

  • Thread starter Thread starter Rachel N
  • Start date Start date
R

Rachel N

I need for the RowSource of a combobox on a form to be one
of two tables depending on the information in a different
combobox on the form. I'm not sure how to do that.

I figured calling a function for the RowSource would be
best, but I can't get it to work. This is the code I
wrote.

<start code>
Public Function fncNotConsented()
Forms!frmAllPts.Refresh
If Forms!frmAllPts![Type of access] = "Fistula" Then
Forms!frmAllPts![If not consented, why?].RowSource
= "tblReasonsNotConsentedFistula"
Else: Forms!frmAllPts![If not consented, why?].RowSource
= "tblReasonsNotConsentedGraft"
End If
End Function
<end code>

This doesn't work. Am I doing this wrong? Is there a
better way?

Thanks!
 
Rachel,

If you want the RowSource of your combo box named, [If not consented, why?],
to change after the user makes a selection from the combo box named, [Type
of Access], use the AfterUpdate event of the [Type of Access] combo box.
Your code (minus the Function - End Function lines should work ok there:

If Me![Type of access] = "Fistula" Then
Me![If not consented, why?].RowSource =
"tblReasonsNotConsentedFistula"
Else
Me![If not consented, why?].RowSource = "tblReasonsNotConsentedGraft"
End If

hth,
 
Back
Top