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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input box info into SQL statment

Status
Not open for further replies.

3535

Programmer
Dec 19, 1999
18
US
I have a line of SQL code that looks like:<br>
If Me.Text2 &lt;&gt; &quot;&quot; Then<br>
SQLStmt=SQLStmt& &quot;(Table1.Terr = ' &quot; & Me.Text2 & &quot; ')&quot;<br>
Endif<br>
<br>
Instead of getting the number from a Unbound field called Me.Text2, I want to get the Number from the answer received from an InputBox.<br>
<br>
The line of code for the InputBox is:<br>
Me.Filter = &quot;Terr = &quot; & InputBox(&quot;Get terr:&quot;, &quot; Get Terr&quot;)<br>
<br>
I need help on what to change in the SQL Code ?<br>
<br>

 
Here are the basics of concatentation<br>
for numeric<br>
SQLStmt = SQLStmt & me!Text2 <br>
if its a string<br>
SQLStmt = SQLStmt & &quot;'&quot; & me!Text2 & &quot;';&quot;<br>
<br>
when you first right code, keep it simple put each step on it's own line<br>
Don't try to create to complex a statement in one line to make it run faster<br>
this will allays cause you problems with syntax.<br>
Here is an example<br>
X= inputbox (somevalue)<br>
Me!filter= &quot;Terr &quot; & X<br>
<br>
Separate the items out and get them to work first then look at making your code more efficient.<br>
On today's Screaming machines the time it takes to go through a few extra lines of code is miniscule<br>
compared to troubleshooting a complex line.<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top