Displaying filtered data from a combobox

  • Thread starter Thread starter Stu
  • Start date Start date
S

Stu

I'm very new to Visual Basic and have little experience, however I have the
following problem that is troubling me;

Within a form I have a combobox, this is filled with a unique number and a
name. When a selection is made from this combobox the details of the
selection are shown on the rest of the form.

I have a checkbox that acts as a filter, when checked certain numbers and
names are excluded from the list. Upon making a selection from this filtered
combobox list, an incorrect record is shown, instead of the details that are
expected. The index number that is used is from the filtered list but the
record details are selected from the original list, therefore getting the
wrong details.

This is what I'm doing;

A) Get the 'Index' of the list item...
Index = [Combo30].ListIndex

B) Use the 'Index' to get the unique number from the list...
Unique_Number = [Combo30].ItemData(Index)

C) Use the 'Unique_Number' to find the record...
DoCmd.FindRecord "Unique_Number", , True, , True, , True

This all appears to work as expected, all I want to do now is display the
record that has been found. I have tried using 'GoToRecord' but do not know
what record number to use or how to get it.

Can anyone help? Thanks.
 
Try ...

me.filter = "fieldName = " & cstr(Unique_Number)
me.filterOn
-----Original Message-----
I'm very new to Visual Basic and have little experience, however I have the
following problem that is troubling me;

Within a form I have a combobox, this is filled with a unique number and a
name. When a selection is made from this combobox the details of the
selection are shown on the rest of the form.

I have a checkbox that acts as a filter, when checked certain numbers and
names are excluded from the list. Upon making a selection from this filtered
combobox list, an incorrect record is shown, instead of the details that are
expected. The index number that is used is from the filtered list but the
record details are selected from the original list, therefore getting the
wrong details.

This is what I'm doing;

A) Get the 'Index' of the list item...
Index = [Combo30].ListIndex

B) Use the 'Index' to get the unique number from the list...
Unique_Number = [Combo30].ItemData(Index)

C) Use the 'Unique_Number' to find the record...
DoCmd.FindRecord "Unique_Number", , True, , True, , True

This all appears to work as expected, all I want to do now is display the
record that has been found. I have tried
using 'GoToRecord' but do not know
 
Back
Top