Combo Box Filtering

  • Thread starter Thread starter rozycki1978
  • Start date Start date
R

rozycki1978

I am trying to use the value in a combo box to filter a form. However,
I have not been able to find the right syntax to make my code work
properly.

Private Sub Combo60_AfterUpdate()

Dim ComboMeal As String
ComboMeal = Me.Combo60

Me.Filter = "[Field Technician] = ComboMeal"
Me.FilterOn = True

End Sub

How can I properly reference the ComboMeal variable within the
Me.Filter statement? Alternatively I could use the value directly from
Me.Combo60 but I have the same syntax or reference problem within the
confines of the Filter statement.

Help is much appreciated!
 
Try placing Field Technician as part of the ComboMeal variable.

ie.

Dim ComboMeal As String
ComboMeal = "[Field Technician] = " & Me.Combo60


Me.Filter = ComboMeal
Me.FilterOn = True

cclark
 
OK. Tried it and it returned all blanks on my forms. [Field
Technician] is a text field taht holds a guy's name. The Combo60 box
is a drop-down that lists each of the available names.

Private Sub Combo60_AfterUpdate()

Me.Filter = "[Field Technician] = """ & Me.Combo60 & """"
Me.FilterOn = True

End Sub

This assumes [Field Technician] is a text field.

I am trying to use the value in a combo box to filter a form. However,
I have not been able to find the right syntax to make my code work
properly.

Private Sub Combo60_AfterUpdate()

Dim ComboMeal As String
ComboMeal = Me.Combo60

Me.Filter = "[Field Technician] = ComboMeal"
Me.FilterOn = True

End Sub

How can I properly reference the ComboMeal variable within the
Me.Filter statement? Alternatively I could use the value directly from
Me.Combo60 but I have the same syntax or reference problem within the
confines of the Filter statement.

Help is much appreciated!
 
I attempted this code and it forced me back into the debugger for a
problem with the Me.FilterOn = True statement.
Try placing Field Technician as part of the ComboMeal variable.

ie.

Dim ComboMeal As String
ComboMeal = "[Field Technician] = " & Me.Combo60


Me.Filter = ComboMeal
Me.FilterOn = True

cclark



I am trying to use the value in a combo box to filter a form. However,
I have not been able to find the right syntax to make my code work
properly.

Private Sub Combo60_AfterUpdate()

Dim ComboMeal As String
ComboMeal = Me.Combo60

Me.Filter = "[Field Technician] = ComboMeal"
Me.FilterOn = True

End Sub

How can I properly reference the ComboMeal variable within the
Me.Filter statement? Alternatively I could use the value directly from
Me.Combo60 but I have the same syntax or reference problem within the
confines of the Filter statement.

Help is much appreciated!
 
In the debug screen it tells me that Me.Combo60 = "25" instead of what
I want which is Me.Combo60 = "Joe Schmoe". 25 is Joe Schmoe's
corresponding ID field number in my 2 column table that provides the
list of field technician names. This solution feels very close except
that I need to get the value out of the second column.

Regards,
cclark said:
Try placing Field Technician as part of the ComboMeal variable.

ie.

Dim ComboMeal As String
ComboMeal = "[Field Technician] = " & Me.Combo60


Me.Filter = ComboMeal
Me.FilterOn = True

cclark



I am trying to use the value in a combo box to filter a form. However,
I have not been able to find the right syntax to make my code work
properly.

Private Sub Combo60_AfterUpdate()

Dim ComboMeal As String
ComboMeal = Me.Combo60

Me.Filter = "[Field Technician] = ComboMeal"
Me.FilterOn = True

End Sub

How can I properly reference the ComboMeal variable within the
Me.Filter statement? Alternatively I could use the value directly from
Me.Combo60 but I have the same syntax or reference problem within the
confines of the Filter statement.

Help is much appreciated!
 
This solution actually works! I had to go into the combo box
properties and change the bound column to "2" instead of "1" and the
filter works perfectly.

I thank everyone for their help! Outstanding!
Private Sub Combo60_AfterUpdate()

Me.Filter = "[Field Technician] = """ & Me.Combo60 & """"
Me.FilterOn = True

End Sub

This assumes [Field Technician] is a text field.

I am trying to use the value in a combo box to filter a form. However,
I have not been able to find the right syntax to make my code work
properly.

Private Sub Combo60_AfterUpdate()

Dim ComboMeal As String
ComboMeal = Me.Combo60

Me.Filter = "[Field Technician] = ComboMeal"
Me.FilterOn = True

End Sub

How can I properly reference the ComboMeal variable within the
Me.Filter statement? Alternatively I could use the value directly from
Me.Combo60 but I have the same syntax or reference problem within the
confines of the Filter statement.

Help is much appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top