Import MS Project Data through Query

D

dbonline

With VBA editor I am trying to build a select statement that extracts data
from the Task table in MS Project. The select by itself works fine, however
when I try to
filter the data with a Where clause I get an error.

Statement:
rsSelect = "Select TaskUniqueId, TaskName, TaskSummary From Tasks Where
TaskSummary = " & chr(34) & "False" & chr(34) & "Order by TaskUniqueId"

When I run the statement I get the error:
Invalid column name "False"

Why does it think this string value "False" is a column? What is wrong with
this syntax? I just want to select rows that are not summary tasks.
 
J

Joel

You may need a carrage returns. The Where requires a new line when I used it
for ACCESS. Not sure if the same applies for project. I have project at work
an not at home. Try this

rsSelect = "Select TaskUniqueId, TaskName, TaskSummary" & vbcrlf & _
"From Tasks" & vbcrlf & _
"Where TaskSummary = " & chr(34) & "False" & chr(34) & vbcrlf & _
"Order by TaskUniqueId"

You don't need chr(34) you can use two sets of double quotes. This is your
preference. I use both styles depending on how bad the code looks. The
chr(34) sometimes make the code harder to read and sometimes easier. I also
like using line continuation character to make the code easier to read.

rsSelect = "Select TaskUniqueId, TaskName, TaskSummary" & vbcrlf & _
"From Tasks" & vbcrlf & _
"Where TaskSummary = ""False"" & vbcrlf & _
"Order by TaskUniqueId"
 

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