Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access - Using list box to choose field to filter on.

Status
Not open for further replies.

gareth001

Technical User
Feb 4, 2003
43
GB
Hi,

I've got a table (tblQuestionnaireComments) which contains fields numbered id_0 to id_50. Within a form (frmCommentReport) there is a text box which generates this number (TxtIDNo) from a list box as the list box only contains 0 to 50. What I can not work out is how to apply a dynamic filter on the table to choose the field needed based on the value of TxtIDNo. This is what I have so far:

Code:
    Field = [Forms]![frmCommentReport]![TxtIDNo]
    Node = [Forms]![frmCommentReport]![TxtNodeID]

    DoCmd.OpenTable ("tblQuestionnaireComments")
    
    tblQuestionnaireComments.ServerFilter = "[Field] = [Node]"

When this is run, I get a "Run-time error '424' object required on the ServerFilter.

TxtNodeID is then used to filter out the records needed from [Field].

Ultimately I want to remove all records that do not match the above criteria so help on the filter or the next stage of deleting the unwanted records would be much appreciated.

Many Thanks Gareth
 
gareth001,
Code:
Set tbl = Screen.ActiveDatasheet
tbl.Filter = [Forms]![frmCommentReport]![TxtIDNo] & _
             "=" & _
             [Forms]![frmCommentReport]![TxtNodeID]
tbl.FilterOn = True

Hope this helps,
CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top