Re: SQL Syntax Error



John,
Thank you for your help. I made a few errors earlier when working
with the code. I am still very new to SQL and code in general,
especially within Access. I fixed the Brackets and a few other
things. here is the newly adapted code:

PARAMETERS [Forms]![QueryMultiValueSearchForm]![txtFilterName] Long,
[Forms]![QueryMultiValueSearchForm]![txtFilterUMID] Long, [Forms]!
[QueryMultiValueSearchForm]![txtProjectGrant] Long;
SELECT [2007-08ScholarshipMaster].*
FROM [2007-08ScholarshipMaster]
WHERE IIf (([Forms]![QueryMultiValueSearchForm]![txtFilterName] Is
Null) ,
IIf([2007-08ScholarshipMaster].Name Like "*" & [Forms]!
[QueryMultiValueSearchForm]![txtFilterName] & "*"))
AND (([Forms]![QueryMultiValueSearchForm]![txtFilterUMID] Is Null)
OR ([2007-08ScholarshipMaster].UMID = [Forms]!
[QueryMultiValueSearchForm]![txtFilterUMID]))
AND (([Forms]![QueryMultiValueSearchForm]![txtProjectGrant] Is
Null)
OR ([2007-08ScholarshipMaster].ProjectGrant = [Forms]!
[QueryMultiValueSearchForm]![txtProjectGrant]))
AND (([Forms]![QueryMultiValueSearchForm]![txtStartDate] Is Null)
OR ([2007-08ScholarshipMaster].ScholarshipStart Like "*" & [Forms]!
[QueryMultiValueSearchForm]![txtStartDate] & "*"))
AND (([Forms]![QueryMultiValueSearchForm]![txtEndDate] Is Null)
OR ([2007-08ScholarshipMaster].ScholarshipEnd Like "*" & [Forms]!
[QueryMultiValueSearchForm]![txtEndDate] & "*"))


I'm going to try to answer your questions about what I think the
statements are doing to the best of my knowledge but I have altered
this code pretty significantly from the original that I found so most
likely I have created some type of syntax error. Basically, I am
trying to create a Query search (So I can use a Print macro) in which
I can enter partial entries and leave some boxes null without it
affecting the search. I think I messed up the "where" statement,
becuase There were other lines of code that had a similar format so I
deleted them and moved other lines up. I realize now that most likely
The syntax for the "where" statement is incorrect becuase of this. If
you would like to see the original code I would be more than happy to
post. To Marshall: thanks for your input, I just checked the spacing
in the parameter clause and it is just fine. To Kingston: If string
comparisons use "or" as a text qualifier does that mean I should
change all my AND statements to OR? This SQL statement is being used
as a Query itself.
Thanks,
M

.



Relevant Pages

  • Re: Rearrange data in a column, Access 2003
    ... I tried this and am getting a 'syntax error, ... I have learned some about SQL, but not enough to figure out the above error. ... "John W. Vinson" wrote: ... this is high-hazard work: ...
    (microsoft.public.access.queries)
  • Re: return a value using MDX
    ... From [Total Revenue] ... but I am getting a syntax error with the. ... it is looking for @sql as well. ... DECLARE @sql varchar ...
    (microsoft.public.sqlserver.olap)
  • Re: C# / SQL Related - whats wrong with this Insert Into syntax?
    ... Strange little problem here... ... I'm getting a "Syntax error in Insert Into statement" when it ... tries to execute the SQL. ... execute it using the MS Access query engine, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Set up Parameter Query to accept more than one entry
    ... Duane Hookom ... "Tim" wrote in message ... > I still get the syntax error even with this latest change. ... >>> If I try to paste the string you recommended directly into SQL View ...
    (microsoft.public.access.queries)
  • Re: sqlite help needed with my proc....
    ... near "'s automotive)": syntax error ... Along with all the other advice, be aware that this sort of thing can ... lead to what's called an "SQL injection attack". ... use sqlite's ability to expand tcl variable names you don't have to worry about injections so much since the whole of your data gets stored in the column rather than being treated as an sql string. ...
    (comp.lang.tcl)