G
Georgios Liakopoulos
Hello and thanks for reading
I want to set the RowSource of a combo box using VBA (because I want to
synchronise it with another combo box but I will not bother you with
this - it works fine).
The problem is that my VBA code does not like the [field1] & "-" &
[field2] AS exp1 syntax in the SQL expression (says Run-time error '13':
Type mismatch). BUT, the same expression works fine placed in the Row
Source property of the control (which does not do the trick because I
cannot set criteria after the WHERE clause).
So, line in VBA code that produces the error:
......
Me!combo2.RowSource = "SELECT subprojects.subproject_id,
[subprojects.subproject_id] & " - " & [subprojects.subproject_name] AS
exp1, subprojects.subproject_name, subprojects.project_id FROM
subprojects WHERE .....///the WHERE clause works fine so I am
simplifying thinks///;"
......
And, alternatively, if I set the Row Source in the control properties to:
SELECT subprojects.subproject_id, [subprojects.subproject_id] & " - " &
[subprojects.subproject_name] AS exp1, subprojects.subproject_name,
subprojects.project_id FROM subprojects;
works fine (but without the ability to dynamically set criteria using a
WHERE clause).
Can anyone explain to me why the
[field1] & "-" & [field2] AS exp1
part of the SQL expression works in the second case (control properties)
but not in the first case (VBA)?
Thank you in advance
I want to set the RowSource of a combo box using VBA (because I want to
synchronise it with another combo box but I will not bother you with
this - it works fine).
The problem is that my VBA code does not like the [field1] & "-" &
[field2] AS exp1 syntax in the SQL expression (says Run-time error '13':
Type mismatch). BUT, the same expression works fine placed in the Row
Source property of the control (which does not do the trick because I
cannot set criteria after the WHERE clause).
So, line in VBA code that produces the error:
......
Me!combo2.RowSource = "SELECT subprojects.subproject_id,
[subprojects.subproject_id] & " - " & [subprojects.subproject_name] AS
exp1, subprojects.subproject_name, subprojects.project_id FROM
subprojects WHERE .....///the WHERE clause works fine so I am
simplifying thinks///;"
......
And, alternatively, if I set the Row Source in the control properties to:
SELECT subprojects.subproject_id, [subprojects.subproject_id] & " - " &
[subprojects.subproject_name] AS exp1, subprojects.subproject_name,
subprojects.project_id FROM subprojects;
works fine (but without the ability to dynamically set criteria using a
WHERE clause).
Can anyone explain to me why the
[field1] & "-" & [field2] AS exp1
part of the SQL expression works in the second case (control properties)
but not in the first case (VBA)?
Thank you in advance