Oct 5th, 2005, 11:26 AM
#1
Thread Starter
New Member
where is the syntax error?
Could anyone tell me what is wrong with my query syntax?
code :
strConditionDates = "(((Mission_Date >= #" & txtDate1 & "#) AND (Mission_Date <= #" & txtDate2 & "#)) AND (Mission_Code = " & Me.ListBoxMission_Code & "))"
Set rstMissions = CurrentDb.OpenRecordset("select distinct FK_Mission_PK from [sql_équipage des missions] where ((FK_MISSION_PK is not null) AND " & strConditionDates)
with the debugger strConditionDates takes the following value:
"(((Mission_Date >= #2005-01-01#) AND (Mission_Date <= #2005-10-05#)) AND (Mission_Code = AI 165 C))"
Attached Images
Oct 5th, 2005, 11:36 AM
#2
Re: where is the syntax error?
The value for Mission_Code needs to be wrapped with single quotes.
VB Code:
strConditionDates = "(((Mission_Date >= #" & txtDate1 & "#) AND (Mission_Date <= #" & txtDate2 & "#)) AND (Mission_Code = '" & Me.ListBoxMission_Code & "'))"
Oct 5th, 2005, 12:17 PM
#3
Thread Starter
New Member
Re: where is the syntax error?
I changed it but I now get this message
Attached Images
Oct 5th, 2005, 12:47 PM
#4
Re: where is the syntax error?
On the first Mission_Date check (right after the first AND) you have three opening (.
So, either one of them needs to be removed, or an additional ) needs to be added to the end.
-tg
Oct 5th, 2005, 01:06 PM
#5
Thread Starter
New Member
Re: where is the syntax error?
this is driving me nuts
ok...here`s what I came up with and still it is not functionning
this is what I see in the The watch when I run the debugger:
"((Mission_Date >= #2005-01-01#) AND (Mission_Date <= #2005-10-05#) AND (Mission_Code = 'AI 165 C'))"
Oct 5th, 2005, 02:18 PM
#6
Re: where is the syntax error?
It looks like you still have mismatched brackets. It is not necessary to bracket each field just the expressions you want to evaluate together.
Assuming I interpreted your intentions correctly, try
VB Code:
strconditiondates = "( (Mission_Date >= #2005-01-01# AND Mission_Date <= #2005-10-05#)
AND Mission_Code = 'AI 165 C' )"
strsql = "select distinct FK_Mission_PK from [sql_équipage des missions]
where FK_MISSION_PK is not null AND " & strconditiondates
The outcome should be
VB Code:
select distinct FK_Mission_PK from [sql_équipage des missions]
where FK_MISSION_PK is not null AND ( (Mission_Date >= #2005-01-01# AND Mission_Date <= #2005-10-05#) AND Mission_Code = 'AI 165 C' )
Oct 5th, 2005, 04:24 PM
#7
Re: where is the syntax error?
Is this valid syntax? FK_MISSION_PK is not null
Shouldn't it read: Not FK_MISSION Is Null ?
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
Oct 5th, 2005, 04:29 PM
#8
Re: where is the syntax error?
Is Not Null is valid syntax.
Oct 6th, 2005, 11:19 AM
#9
Thread Starter
New Member
Re: where is the syntax error?
My query was functionning until I added strConditionDates . Therefore I assume that "is not full" works.....
I have tried all suggestions listed above but no succces.
Any other suggestions?
thanks
Oct 6th, 2005, 02:11 PM
#10
Hyperactive Member
Re: where is the syntax error?
VB Code:
strConditionDates = "[Mission_Date] >= #" & txtDate1 & "# AND [Mission_Date] <= #" & txtDate2 & "# AND [Mission_Code] =‘" & Me.ListBoxMission_Code & "’""
Set rstMissions = CurrentDb.OpenRecordset("select distinct FK_Mission_PK from [sql_équipage des missions] where [FK_MISSION_PK] is not null AND " & strConditionDates)
just a try
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width