Due to some quirky business rules, I need a combobox on a form to use different rowsets for different records. In my specific example, one record in a household has a relationship of "self." Any other record will have the choice of any possible relationship except "self." So I have code that looks like this:
Private Sub Rol_ID_GotFocus()
If Nz(Per_SSN.Value) = Nz(Form_Main.Hou_Per_SSN) Then
Rol_ID.RowSource = "SELECT Role.Rol_Description, Role.Rol_ID FROM Role WHERE Role.Rol_ID = 1;"
Else
Rol_ID.RowSource = "SELECT Role.Rol_Description, Role.Rol_ID FROM Role WHERE Role.Rol_ID > 1;"
End If
End Sub
This field is displayed in a subform in datasheet view on the "Main" form. However, the comboboxes DON'T always display their value. I may have two people, one with a role of "Self," and one with a role of "Daughter." When I load the form, the first person's rol_id will show "Self," and the second one will be blank. If I click on the daughter's Rol_ID and then click something, both values display- until I, say, switch windows, and then ONLY the daughter's role displays, not the "Self". The correct values are stored, and the drop-down is populated only with the correct choices, but they are not always displayed.
Now here's the REALLY quirky bit. It worked just fine in the last backup I made (yes, I pulled it up and checked). I changed the Main form, but made no alterations in this subform... yet, even if I look at it directly in the subform instead of through the Main form, it still misbehaves. Any ideas?
Private Sub Rol_ID_GotFocus()
If Nz(Per_SSN.Value) = Nz(Form_Main.Hou_Per_SSN) Then
Rol_ID.RowSource = "SELECT Role.Rol_Description, Role.Rol_ID FROM Role WHERE Role.Rol_ID = 1;"
Else
Rol_ID.RowSource = "SELECT Role.Rol_Description, Role.Rol_ID FROM Role WHERE Role.Rol_ID > 1;"
End If
End Sub
This field is displayed in a subform in datasheet view on the "Main" form. However, the comboboxes DON'T always display their value. I may have two people, one with a role of "Self," and one with a role of "Daughter." When I load the form, the first person's rol_id will show "Self," and the second one will be blank. If I click on the daughter's Rol_ID and then click something, both values display- until I, say, switch windows, and then ONLY the daughter's role displays, not the "Self". The correct values are stored, and the drop-down is populated only with the correct choices, but they are not always displayed.
Now here's the REALLY quirky bit. It worked just fine in the last backup I made (yes, I pulled it up and checked). I changed the Main form, but made no alterations in this subform... yet, even if I look at it directly in the subform instead of through the Main form, it still misbehaves. Any ideas?