B
Bruce
I have asked variants of this question before, and have
received a variety of answers, but none of them have
worked, probably because I left something out of my
description.
I have a training records database that works well for
entering training information. It contains 20 or so
fields, but let us say that it contains just the fields
[PrimaryKey], [Subject], [PartNumber], and [Department].
It works by entering training information on a form, and
attendance on a subform. The subform is linked to the
main form through the PK of the main form. It works as
intended, and can probably be ignored in considering the
following questions. The underlying table for training
session information is tblTrainingSession, and the
associated form is frmTrainingSession. The value in any
one of the fields I mentioned (except PK) is present for
many reords. I can right click on a field (on the form)
and filter by selection, so that for instance I could find
all records where the subject is Masking. The main
problems are 1) I first need to find a record with that
subject, and 2) it would be better if this could be
accomplished by combo box, command button, or other
visible control.
I would prefer to use a combo box to locate, say, Masking
as the subject. After that I woud like to find all
records that contain Masking as the subject. I can set up
a combo box (cboLookupSubject) with the following in the
After Update event:
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[PrimaryKey] = " & Str(Me!_
[cboLookupSubject])
Me.Bookmark = rs.Bookmark
The underscore is supposed to indicate no line break. I
don't remember if I got the code from the wizard or from a
newsgroup, and I don't fully understand what it is doing.
The combo box row source is:
SELECT DISTINCT tblTrainingSession.*,
tblTrainingSession.Subject
FROM tblTrainingSession
WHERE (((tblTrainingSession.Subject) Is Not Null))
ORDER BY tblTrainingSession.Subject;
This shows [Subject] for all of the records, but if there
are 20 records with the subject Masking, all 20 will show
up on the list. I can select one of those records, then
right click on [txtSubject] on the form to filter by
selection, but I would like to do all of that with fewer
steps and without the need for the right click menu.
What I need is for the combo box to display a list
containing no duplicate items. I would like the After
Update event for the combo box to filter by the combo box
selection, but a command button would be OK for that.
The main form is in the Detail section. Does it matter
where the combo box is located (Header, Detail, etc.), or
is one better than the other? Is it a problem doing this
on the same form where I add new records?
received a variety of answers, but none of them have
worked, probably because I left something out of my
description.
I have a training records database that works well for
entering training information. It contains 20 or so
fields, but let us say that it contains just the fields
[PrimaryKey], [Subject], [PartNumber], and [Department].
It works by entering training information on a form, and
attendance on a subform. The subform is linked to the
main form through the PK of the main form. It works as
intended, and can probably be ignored in considering the
following questions. The underlying table for training
session information is tblTrainingSession, and the
associated form is frmTrainingSession. The value in any
one of the fields I mentioned (except PK) is present for
many reords. I can right click on a field (on the form)
and filter by selection, so that for instance I could find
all records where the subject is Masking. The main
problems are 1) I first need to find a record with that
subject, and 2) it would be better if this could be
accomplished by combo box, command button, or other
visible control.
I would prefer to use a combo box to locate, say, Masking
as the subject. After that I woud like to find all
records that contain Masking as the subject. I can set up
a combo box (cboLookupSubject) with the following in the
After Update event:
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[PrimaryKey] = " & Str(Me!_
[cboLookupSubject])
Me.Bookmark = rs.Bookmark
The underscore is supposed to indicate no line break. I
don't remember if I got the code from the wizard or from a
newsgroup, and I don't fully understand what it is doing.
The combo box row source is:
SELECT DISTINCT tblTrainingSession.*,
tblTrainingSession.Subject
FROM tblTrainingSession
WHERE (((tblTrainingSession.Subject) Is Not Null))
ORDER BY tblTrainingSession.Subject;
This shows [Subject] for all of the records, but if there
are 20 records with the subject Masking, all 20 will show
up on the list. I can select one of those records, then
right click on [txtSubject] on the form to filter by
selection, but I would like to do all of that with fewer
steps and without the need for the right click menu.
What I need is for the combo box to display a list
containing no duplicate items. I would like the After
Update event for the combo box to filter by the combo box
selection, but a command button would be OK for that.
The main form is in the Detail section. Does it matter
where the combo box is located (Header, Detail, etc.), or
is one better than the other? Is it a problem doing this
on the same form where I add new records?