ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Controlling ODBC queries with VB variables (https://www.excelbanter.com/excel-programming/314018-controlling-odbc-queries-vbulletin-variables.html)

vehement[_3_]

Controlling ODBC queries with VB variables
 

The correct way to pass a variable is like this:

"WHERE (`ORDER PROJECTIONS`.LB4= ' " & Var & " ')"

Notice the double qoutes nested within the single qoutes. VB think
your ending the query string otherwise. Thanks again Eric.

This is a good site for writing queries in Office VBA
http://www.fontstuff.com/access/acctut15.ht

--
vehemen
-----------------------------------------------------------------------
vehement's Profile: http://www.excelforum.com/member.php...fo&userid=1541
View this thread: http://www.excelforum.com/showthread.php?threadid=27022


MarkInSalemOR

Controlling ODBC queries with VB variables
 
Careful if the backend database is DB2 and the data field is numeric those
single quotes are going to cause a type mismatch error.

Mark

"vehement" wrote:


The correct way to pass a variable is like this:

"WHERE (`ORDER PROJECTIONS`.LB4= ' " & Var & " ')"

Notice the double qoutes nested within the single qoutes. VB thinks
your ending the query string otherwise. Thanks again Eric.

This is a good site for writing queries in Office VBA
http://www.fontstuff.com/access/acctut15.htm


--
vehement
------------------------------------------------------------------------
vehement's Profile: http://www.excelforum.com/member.php...o&userid=15417
View this thread: http://www.excelforum.com/showthread...hreadid=270221




All times are GMT +1. The time now is 03:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com