Filter in a form using a combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I was wondering if anyone would be able to help me?
I am trying to create a form in Tabular layout.
I have created a combo box whereby I want to enter a description and when I
press Enter I want it to filter on that description.

Does anyone know how to do this?

Cheers
 
Unbound combo boxes are the best control for searching and filtering. Use
the After Update event of the combo:

Private Sub cboFilterForm_AfterUpdate()

If IsNull(Me.cboFilterForm) Then 'Remove the filter
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[Description] = '" & Me.cboFilterForm & "'"
Me.FilterOn = True
End If

End Sub
 
Thanks Dave.
I will give this a try.
I am just beginning to learn Visual Studio.NET from a text book,
I am not confident yet... But give it a while!

Thanks again

Klatuu said:
Unbound combo boxes are the best control for searching and filtering. Use
the After Update event of the combo:

Private Sub cboFilterForm_AfterUpdate()

If IsNull(Me.cboFilterForm) Then 'Remove the filter
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[Description] = '" & Me.cboFilterForm & "'"
Me.FilterOn = True
End If

End Sub
--
Dave Hargis, Microsoft Access MVP


AJCB said:
Hi,
I was wondering if anyone would be able to help me?
I am trying to create a form in Tabular layout.
I have created a combo box whereby I want to enter a description and when I
press Enter I want it to filter on that description.

Does anyone know how to do this?

Cheers
 
Sorry to sound a little stupid, but in this string, do I need to replace the
existing information already in the box which reads:

Private Sub Combo38FilterForm_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[StockCode] = '" & Me![Combo38] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Klatuu said:
Unbound combo boxes are the best control for searching and filtering. Use
the After Update event of the combo:

Private Sub cboFilterForm_AfterUpdate()

If IsNull(Me.cboFilterForm) Then 'Remove the filter
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[Description] = '" & Me.cboFilterForm & "'"
Me.FilterOn = True
End If

End Sub
--
Dave Hargis, Microsoft Access MVP


AJCB said:
Hi,
I was wondering if anyone would be able to help me?
I am trying to create a form in Tabular layout.
I have created a combo box whereby I want to enter a description and when I
press Enter I want it to filter on that description.

Does anyone know how to do this?

Cheers
 
Okay, you have until Friday to become a world renowned expert. If that is
not doable, plan to work this weekend :)

Interesting you mentioned .net, Access does not use .net.
--
Dave Hargis, Microsoft Access MVP


AJCB said:
Thanks Dave.
I will give this a try.
I am just beginning to learn Visual Studio.NET from a text book,
I am not confident yet... But give it a while!

Thanks again

Klatuu said:
Unbound combo boxes are the best control for searching and filtering. Use
the After Update event of the combo:

Private Sub cboFilterForm_AfterUpdate()

If IsNull(Me.cboFilterForm) Then 'Remove the filter
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[Description] = '" & Me.cboFilterForm & "'"
Me.FilterOn = True
End If

End Sub
--
Dave Hargis, Microsoft Access MVP


AJCB said:
Hi,
I was wondering if anyone would be able to help me?
I am trying to create a form in Tabular layout.
I have created a combo box whereby I want to enter a description and when I
press Enter I want it to filter on that description.

Does anyone know how to do this?

Cheers
 
Yes, replace what you have with what Dave gave you. You should end up with:

Private Sub Combo38FilterForm_AfterUpdate()
If IsNull(Me.Combo38FilterForm) Then 'Remove the filter
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[Description] = '" & Me.Combo38FilterForm & "'"
Me.FilterOn = True
End If
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


AJCB said:
Sorry to sound a little stupid, but in this string, do I need to replace
the
existing information already in the box which reads:

Private Sub Combo38FilterForm_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[StockCode] = '" & Me![Combo38] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Klatuu said:
Unbound combo boxes are the best control for searching and filtering.
Use
the After Update event of the combo:

Private Sub cboFilterForm_AfterUpdate()

If IsNull(Me.cboFilterForm) Then 'Remove the filter
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[Description] = '" & Me.cboFilterForm & "'"
Me.FilterOn = True
End If

End Sub
--
Dave Hargis, Microsoft Access MVP


AJCB said:
Hi,
I was wondering if anyone would be able to help me?
I am trying to create a form in Tabular layout.
I have created a combo box whereby I want to enter a description and
when I
press Enter I want it to filter on that description.

Does anyone know how to do this?

Cheers
 
Morning...
Thanks for this, but it didn't work.
clicked the ... button against 'After Update', selected 'Code Builder',
pasted the string into the Visual Basic Window.
Then, I am not sure if this is right or not, but I went to Debug and clicked
'Compile AJB Stock Database' and an error message came up stating 'Compile
Error, Method or Data member not found'.... It highlights the string Is Null
".ComboFilterForm)"

Any ideas as to why?
Also, do I have to type 'Event Procedure' in the After Update section, or
should this automatically be put in by Visual Basic?



Douglas J. Steele said:
Yes, replace what you have with what Dave gave you. You should end up with:

Private Sub Combo38FilterForm_AfterUpdate()
If IsNull(Me.Combo38FilterForm) Then 'Remove the filter
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[Description] = '" & Me.Combo38FilterForm & "'"
Me.FilterOn = True
End If
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


AJCB said:
Sorry to sound a little stupid, but in this string, do I need to replace
the
existing information already in the box which reads:

Private Sub Combo38FilterForm_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[StockCode] = '" & Me![Combo38] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Klatuu said:
Unbound combo boxes are the best control for searching and filtering.
Use
the After Update event of the combo:

Private Sub cboFilterForm_AfterUpdate()

If IsNull(Me.cboFilterForm) Then 'Remove the filter
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[Description] = '" & Me.cboFilterForm & "'"
Me.FilterOn = True
End If

End Sub
--
Dave Hargis, Microsoft Access MVP


:

Hi,
I was wondering if anyone would be able to help me?
I am trying to create a form in Tabular layout.
I have created a combo box whereby I want to enter a description and
when I
press Enter I want it to filter on that description.

Does anyone know how to do this?

Cheers
 

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