Bob Gajewski
rbgajewski at adelphia.net
Thu Jun 5 22:58:55 CDT 2008
I have a form with combobox fields for various ambulance personnel: Driver,
Assistant, Attendant1, Attendant2, and Attendant3. Each combobox has the
LimitToList property set to "No". This form is bound to tblMembers, which
includes 3 attribute flags (Yes/No fields): booMember, booMemberActive, and
booMemberEMS.
I have 3 queries on the table:
qryMembers - returns all records where booMember=True
qryMembersActive - returns all records where booMember=True And
booMemberActive=True
qryMembersEMS - returns all records where booMember=TrueAnd
booMemberActive=True And booMemberEMS=True
In the Form_Current module, I initialize the combobox fields:
Driver.RowSource = "SELECT '(Show All Members)' from qryMembersActive UNION
SELECT DISTINCT [FullName] from qryMembersActive"
Assistant.RowSource = "SELECT '(Show All Members)' from qryMembersActive
UNION SELECT DISTINCT [FullName] from qryMembersActive"
Attendant1.RowSource = "SELECT '(Show All Active)' from qryMembersEMS UNION
SELECT '(Show All Members)' from qryMembersEMS UNION SELECT DISTINCT
[FullName] from qryMembersEMS"
Attendant2.RowSource = "SELECT '(Show All Active)' from qryMembersEMS UNION
SELECT '(Show All Members)' from qryMembersEMS UNION SELECT DISTINCT
[FullName] from qryMembersEMS"
Attendant3.RowSource = "SELECT '(Show All Active)' from qryMembersEMS UNION
SELECT '(Show All Members)' from qryMembersEMS UNION SELECT DISTINCT
[FullName] from qryMembersEMS"
So far, so good - the code *works perfectly*. For the rest of this question,
I'll only refer to one - Attendant3.
In the _BeforeUpdate module, I test for the selection of the 'Show All'
values, and if selected, I update the RowSource:
Private Sub Attendant3_BeforeUpdate(Cancel As Integer)
If Attendant3 = "(Show All Active)" Then
MsgBox ("Please select a valid Active Member or enter a non-Member's
name (last name, first name).")
Attendant3.RowSource = "SELECT '(Show All Members)' from
qryMembersActive UNION SELECT DISTINCT [FullName] from qryMembersActive"
Cancel = True
ElseIf Attendant3 = "(Show All Members)" Then
MsgBox ("Please select a valid Member or enter a non-Member's name (last
name, first name).")
Attendant3.RowSource = "qryMembers"
Cancel = True
End If
End Sub
My problem? I want the combobox to show a default value nothing if either of
the "Show All" options is selected, but after the Cancel=True executes,
control is returned to the combobox with the proper row source but with the
"Show All" selection showing in the combobox. How do I blank that out?
I have tried Attendant3="" and Attendant3=Null both on the line before and
the line after the Cancel=True.
I have run out of ideas. Any suggestions?
TIA, Bob Gajewski