Phil Budge

New Member
Licensed User
With the Table.Filter command is it possible to use variables as the Column and Arguement as I can only make this function work with fixed values.


Well-Known Member
Licensed User
Longtime User
Hi Phil,

let's take the following Table

Table1.AddCol(cNumber, "Number", 50)
Table1.AddCol(cString, "Value1", 50)
Table1.AddCol(cString, "Value2", 50)

Table1.AddRow(1, "A1", "red")
Table1.AddRow(1, "A2", "green")
Table1.AddRow(2, "A2", "blue")
Table1.AddRow(2, "A2", "white")
Table1.AddRow(2, "A4", "black")

and these two variables

arg1 = 2
arg2 = "A2"

For a column with cNumber format we could code this filter

Table1.Filter("Number = " & arg1)

Result: the rows with "blue", "black" and "white".

To code a filter with a column of cString format you have to add some ' around the variables like

Table1.Filter("Value1 = '" & arg2 & "'")

Result: the rows with "green", "blue" and white.