View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Excel VBA putting text from textbox into SQL statement

Jon,
Try something like


Dim SQL As String
SQL = "SELECT blah blah blah " & _
"WHERE DATA = `" & userform1.TextBox.Text & "'"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)



wrote in message
ps.com...
Hi all, I have an SQL statement which I would like to have a variable
"WHERE" section. For example:

SELECT blah blah blah
WHERE DATA = variabledata.text


(where the variabledata.text is text from a text box.) Is this possible
to do?

Basically, the spreadsheet opens and asks for a "period" which is a
number between 1 and 3. The user then puts this into the inputbox and I
want that text to go into the variabledata.text part of the statement.

I hope this is enough info!

Any help is much appretiated,

Regards,

Jon.