Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

QUERY SYNTAX

Status
Not open for further replies.

villica

Programmer
Feb 25, 2000
332
CA
I have the following code under open report. It does exactly what I want. <br><br>SQL = &quot;SELECT * from &quot; & Forms!frmlogdate!logfile & &quot; where &quot; & Forms!frmlogdate!logfile & &quot;!Initials = &quot;&quot;&quot; & Forms![frmlogdate]![INITIALS] & &quot;&quot;&quot;&quot;<br><br>I want to append the following code to the above query and I am not sure how to do it.&nbsp;&nbsp;I am just not sure where do you put quotes to end the query statement. It is probably very simple but I am having a lot of probles with query syntax. <br><br>&nbsp;and Forms!frmlogdate!logfile.logdate Is Not Null And Between [Forms]![frmlogdate]![BeginningDate] And [Forms]![frmlogdate]![EndingDate]<br><br><br>Any help will be appreciated.<br> <p>Villica<br><a href=mailto:villica67@hotmail.com>villica67@hotmail.com</a><br><a href= > </a><br>
 
Huh ?<br><br>SQL = &quot;SELECT * from &quot; & Forms!frmlogdate!logfile & &quot; where &quot; & Forms!frmlogdate!logfile & &quot;.Initials = &quot;&quot;&quot; & Forms![frmlogdate].[INITIALS] & &quot;&quot;&quot; and #&quot; & Forms!frmlogdate!logfile & &quot;.logdate # Is Not Null And #&quot; & [Forms]![frmlogdate].[BeginningDate] &&quot; # &gt;= #&quot; & Forms!frmlogdate!logfile & &quot;.logdate # And #&quot; & [Forms]![frmlogdate].[EndingDate] & &quot;# &lt;= #&quot; & Forms!frmlogdate!logfile & &quot;.logdate #&quot;<br><br><font color=red>You can greatly simplify your work by using the name of the logfile table</font>:<br><br>SQL = &quot;SELECT * from tblLogFile where tblLogFile.Initials =&quot;&quot;&quot; & Forms![frmlogdate].[INITIALS] & &quot;&quot;&quot; and tblLogFile.logdate Is Not Null And #&quot; & Forms![frmlogdate].[BeginningDate] & &quot; # &gt;= tblLogFile.logdate And #&quot; & Forms![frmlogdate].[EndingDate]& &quot;# &lt;= tblLogFile.logdate&quot;<br><br>Whew !<br> <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
Amiel thank you for your help, but I am getting a syntax error on the code you gave me.<br>SQL = &quot;SELECT * from &quot; & Forms!frmlogdate!logfile & &quot; where &quot; &<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Forms!frmlogdate!logfile & &quot;.Initials = &quot;&quot;&quot; & Forms![frmlogdate].[INITIALS] &<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&quot; and #&quot; & Forms!frmlogdate!logfile & &quot;.logdate# Is Not Null And #&quot; &<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Forms]![frmlogdate].[BeginningDate] &&quot; # &gt;= #&quot; & Forms!frmlogdate!logfile &<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;.logdate# And #&quot; & [Forms]![frmlogdate].[EndingDate] & &quot;# &lt;= #&quot; &<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Forms!frmlogdate!logfile & &quot;.logdate#&quot;<br><br><br>I removed any spaces before the # but it still gives me a syntax error<br>Any other suggestions. Thanks <p>Villica<br><a href=mailto:villica67@hotmail.com>villica67@hotmail.com</a><br><a href= > </a><br>
 
Typically the text of the syntax error message will display the query string that caused the error. I cannnot see that and cannot identify the exact error. A couple of questions if I may. Is this query being executed from the form frmlogdate?<br><br>If it is remove the line &quot;Forms![frmlogdate].[BeginningDate] and replace it with, &quot;[BeginningDate]&quot;<br><br>Is there more than one logfile? If not replace <br>&quot;Forms!frmlogdate!logfile&quot; with the name of the 'logfile' table<br><br>It should now look like this:<br><br>&quot;SELECT * from tblLogFile where&quot; & _&nbsp;&nbsp;<br>&quot;Initials = &quot;&quot;&quot; &&nbsp;&nbsp;[INITIALS] & &quot;&quot;&quot; and Beginningdate &gt;=#&quot; & [BeginningDate] & &quot;#&nbsp;&nbsp;and logdate &lt;= #&quot; & [enddate] & &quot;#&quot;<br><br><br>-----------------------------------------------------------<br>If the above two questions are not the case you will have to play with the quotation marks for the two items replacing tblLogFile with the string &quot;Forms![frmlogdate]!Controls.[BeginningDate]&quot;;&nbsp;&nbsp;notice the placement of the dot. The statement extracting null values was removed all together, it's not necessary.<br><br>Alse I noticed the statement <br>&quot;!Initials = &quot;&quot;&quot; & Forms![frmlogdate]![INITIALS] & &quot;&quot;&quot;&quot;<br>this can be misleading '!Initials'&nbsp;&nbsp;is part of a literal string being compared against the value [INTIALS] from the form. If the literal string &quot;!Initials&quot; never matches the literal string [INTIALS] on the form, it'll be ok. It won't cause an error and it also won't be doing what we may think it's doing.<br><br>I'm afraid that I'd have to have the .mdb and see exactly what you want to accomplish to handle this one.<br> <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top