Hi,
I've created a combo box called Purpose_combo in Access. I populate this combo box with a list of values (such as "Response";"Reply"; "Advice")that are not generated from an SQL query. I only get its indexed number instead of the string when I use debug.print Purpose_Combo, such as I have got 1 for Response, 2 for Reply, 3 for Advice. When I use this value as a conditional statement in a sql query (such as, select * from table where table.Purpose like "'" & Purpose_Combo & "'"), the query doesn't work. The data type of table.Purpose is text.
I have tried it using Purpose_Combo.Column(1). However, it is only working in the VBA program, not in SQL query. When I put Purpose_Combo.Column(1) in the query and ran it, an error message is displayed saying that "Undefined function Column() in expression" . I think that Column() function is not recognized by SQL.
I have also tried to use Decode () in the query, such as select * from table where table.Purpuose like Decode(Purpose_Combo, 1, 'Response', 2, 'Reply', 3, 'Advice', ''), but I got the same error as using Purpose_Combo.Column(1).
Does anyone know how to solve this problem? Thanks in advance.
vicgirl
I've created a combo box called Purpose_combo in Access. I populate this combo box with a list of values (such as "Response";"Reply"; "Advice")that are not generated from an SQL query. I only get its indexed number instead of the string when I use debug.print Purpose_Combo, such as I have got 1 for Response, 2 for Reply, 3 for Advice. When I use this value as a conditional statement in a sql query (such as, select * from table where table.Purpose like "'" & Purpose_Combo & "'"), the query doesn't work. The data type of table.Purpose is text.
I have tried it using Purpose_Combo.Column(1). However, it is only working in the VBA program, not in SQL query. When I put Purpose_Combo.Column(1) in the query and ran it, an error message is displayed saying that "Undefined function Column() in expression" . I think that Column() function is not recognized by SQL.
I have also tried to use Decode () in the query, such as select * from table where table.Purpuose like Decode(Purpose_Combo, 1, 'Response', 2, 'Reply', 3, 'Advice', ''), but I got the same error as using Purpose_Combo.Column(1).
Does anyone know how to solve this problem? Thanks in advance.
vicgirl
Last edited: