Record search - when value not found display blank vs display all

M

Mesa

Well, I appreciate any help on this one. I have a drop down combo box
that is coded on afterupdate function. Inside the form is a sub-form
which displays all one-to-many relationship records that the combo box
controls. Currently, it is programed to display all records with the
same value as the combo box. The problem is that if the value that i
select is not found in any record, it displays all records. I want to
program it so that if i select a value and there are no records that
share the same value, it will then display the sub-form as blank.

Here is what i got so far



Private Sub Combo68_AfterUpdate()
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Training] = '" & Me![Combo68] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub



Any links to databases or coding suggestions that resolve my conflict
will be greatly appreciated.
 
T

tina

do you actually have a subform inside the main form? because the code you
posted will find a record in the *main* form, not in the subform.

if you do have a mainform/subform setup, suggest you get rid of the code and
instead use the LinkChildFields and LinkMasterFields properties of the
subform control, to link the subform to the combo box control on the main
form. the LinkMasterFields property should be set to [Combo68], and the
LinkChildFields property should be set to [Training]. do this in the
property box in the main form, *not* via code.

hth
 
Top