filtering a form by combo in the header

C

crtopher

My form has txtFirstName, txtSurname, and cboCategoryID;

cboCategoryID rowsource is:
SELECT lkupProcedureCat.ProcedureCatID, lkupProcedureCat.ProcedureCat,
lkupProcedureCat.Use FROM lkupProcedureCat WHERE
(((lkupProcedureCat.Use)="surgeon")) OR (((lkupProcedureCat.Use)="both"))
ORDER BY lkupProcedureCat.ProcedureCat;

In the header i have cboFilter with the same rowsource:


I have this code in the AfterUpdate of the cboFilter:

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

End Sub

....which i got from another post to this forum (thankyou).

The problem is that when i select the filter item from the cbofilter i get
a message box


Enter parameter value: cboCategoryID

Thank you in advance for your suggestions

CHeers
Chris
 
O

Ofer Cohen

The filter should apply to the field in the table,
Looking at this line

Me.Filter = "[cboCategoryID] = '" & Me.cbofilter & "'"

Are you sure that cboCategoryID it's the name of the field in the table?
Usually people use cbo.. to indcate a combo

Should be
Me.Filter = "[NameOfFieldInTheTableYouFilterOn] = '" & Me.cbofilter & "'"
 
C

crtopher

BS"D...

you are a legend. Working now like a treat! Sorry to be such a LOSER!!

Cheers
Chris

Ofer Cohen said:
The filter should apply to the field in the table,
Looking at this line

Me.Filter = "[cboCategoryID] = '" & Me.cbofilter & "'"

Are you sure that cboCategoryID it's the name of the field in the table?
Usually people use cbo.. to indcate a combo

Should be
Me.Filter = "[NameOfFieldInTheTableYouFilterOn] = '" & Me.cbofilter & "'"
--
Good Luck
BS"D


crtopher said:
My form has txtFirstName, txtSurname, and cboCategoryID;

cboCategoryID rowsource is:
SELECT lkupProcedureCat.ProcedureCatID, lkupProcedureCat.ProcedureCat,
lkupProcedureCat.Use FROM lkupProcedureCat WHERE
(((lkupProcedureCat.Use)="surgeon")) OR (((lkupProcedureCat.Use)="both"))
ORDER BY lkupProcedureCat.ProcedureCat;

In the header i have cboFilter with the same rowsource:


I have this code in the AfterUpdate of the cboFilter:

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

End Sub

...which i got from another post to this forum (thankyou).

The problem is that when i select the filter item from the cbofilter i get
a message box


Enter parameter value: cboCategoryID

Thank you in advance for your suggestions

CHeers
Chris
 

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

Top