ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SQL Select Where - formatting (https://www.excelbanter.com/excel-programming/383100-sql-select-where-formatting.html)

Peter Hesselager

SQL Select Where - formatting
 
Hi Group.
I got good help earlier, so once again I ask for help.
I recorded a macro, where in the query I set DebKart.Sælger = 1
and it worked.
Now I want to get this variable from Sheet2!G13.
But I don't know how to format the SalesPerson value for the SELECT string
to work.

Any help ?
------------------------------------------------------
Dim SalesPerson As Integer
SalesPerson = Range("Sheet2!G13").Value
'
"SELECT DebKart.Konto, DebKart.Navn, DebKart.Sælger" & Chr(13) & ""
& Chr(10) & "FROM DebKart DebKart" & Chr(13) & "" & Chr(10) & "WHERE
(DebKart.Sælger= SalesPerson)" _

--
Med venlig hilsen
Peter Hesselager-Olesen
SBS-IT Aps


NickHK

SQL Select Where - formatting
 
Peter,
You mean like this ?

"SELECT DebKart.Konto, DebKart.Navn, DebKart.Sælger" & vbNewLine & "FROM
DebKart DebKart" & vbNewLine & "WHERE (DebKart.Sælger=""" & SalePerson &
""")........"

Also, you can use vbNewLine instead.

NickHK

"Peter Hesselager" wrote in
message ...
Hi Group.
I got good help earlier, so once again I ask for help.
I recorded a macro, where in the query I set DebKart.Sælger = 1
and it worked.
Now I want to get this variable from Sheet2!G13.
But I don't know how to format the SalesPerson value for the SELECT string
to work.

Any help ?
------------------------------------------------------
Dim SalesPerson As Integer
SalesPerson = Range("Sheet2!G13").Value
'
"SELECT DebKart.Konto, DebKart.Navn, DebKart.Sælger" & Chr(13) &

""
& Chr(10) & "FROM DebKart DebKart" & Chr(13) & "" & Chr(10) & "WHERE
(DebKart.Sælger= SalesPerson)" _

--
Med venlig hilsen
Peter Hesselager-Olesen
SBS-IT Aps





All times are GMT +1. The time now is 01:41 PM.

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