combo box

  • Thread starter Thread starter Chrissy
  • Start date Start date
C

Chrissy

I give up! I need help. I am trying to learn this
program as an amateur.

My form is based on personnel. I want the user to select
a location, via the combo box, and retrieve only those
records of employees that work the location the user
selects.

I used the wizard and chose the third option. Since my
locations are located in a table not included in the
query for the form, I changed my row source to the table
with the locations.

SELECT [qry90Locations].[Location] FROM [qry90Locations]

Since I want to return only the records for the employees
working the selected location, I think I am missing a
WHERE component. I have tried several variations to no
avail.

My combo box is named [cboLocations] and [Location] is
the field name as stored in the form's source table.

Any takers?

Thanks -- I hope.
 
Comments interspersed:

Chrissy said:
I give up! I need help. I am trying to learn this
program as an amateur.

My form is based on personnel. I want the user to select
a location, via the combo box, and retrieve only those
records of employees that work the location the user
selects.

I used the wizard and chose the third option.

That is not what the third option does. The third option essentially does a
"Find" on the form based on the value selected in the Combo. EXAMPLE: The
form's RecordSet has 10 records and both the second and eighth one have the name
"Bob Jones" in one field. If you set up a Combo using the third option from the
wizard selecting "Bob Jones" in the Combo will cause the form to navigate to the
second record (the first one that matches). You will still see all 10 records
in the forms navigation bar and you will not yet be aware that there is another
matching record at the eighth position.

Since my
locations are located in a table not included in the
query for the form, I changed my row source to the table
with the locations.

SELECT [qry90Locations].[Location] FROM [qry90Locations]

Since I want to return only the records for the employees
working the selected location, I think I am missing a
WHERE component. I have tried several variations to no
avail.

My combo box is named [cboLocations] and [Location] is
the field name as stored in the form's source table.

What you want is to apply a filter based on the value in the ComboBox. In the
AfterUpdate event of the Combo have code similar to...

Me.Filter = "[SomeField] = '" & Me.ComboBoxName & "'"
Me.FilterOn = True

In the above example, now when "Bob Jones" is selected from the Combo the form
will be filtered and the navigation bar will show two records (the two that
match).

My sample syntax assumes that the value being filtered on is Text. If it were
numeric you would eliminate the quotes around the Combo value.
 
Rick, once again....to the rescue. Thanks. Works like a
charm.

Thanks for the help.

-----Original Message-----
Comments interspersed:

Chrissy said:
I give up! I need help. I am trying to learn this
program as an amateur.

My form is based on personnel. I want the user to select
a location, via the combo box, and retrieve only those
records of employees that work the location the user
selects.

I used the wizard and chose the third option.

That is not what the third option does. The third option essentially does a
"Find" on the form based on the value selected in the Combo. EXAMPLE: The
form's RecordSet has 10 records and both the second and eighth one have the name
"Bob Jones" in one field. If you set up a Combo using the third option from the
wizard selecting "Bob Jones" in the Combo will cause the form to navigate to the
second record (the first one that matches). You will still see all 10 records
in the forms navigation bar and you will not yet be aware that there is another
matching record at the eighth position.

Since my
locations are located in a table not included in the
query for the form, I changed my row source to the table
with the locations.

SELECT [qry90Locations].[Location] FROM [qry90Locations]

Since I want to return only the records for the employees
working the selected location, I think I am missing a
WHERE component. I have tried several variations to no
avail.

My combo box is named [cboLocations] and [Location] is
the field name as stored in the form's source table.

What you want is to apply a filter based on the value in the ComboBox. In the
AfterUpdate event of the Combo have code similar to...

Me.Filter = "[SomeField] = '" & Me.ComboBoxName & "'"
Me.FilterOn = True

In the above example, now when "Bob Jones" is selected from the Combo the form
will be filtered and the navigation bar will show two records (the two that
match).

My sample syntax assumes that the value being filtered on is Text. If it were
numeric you would eliminate the quotes around the Combo value.


.
 
Back
Top