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

Variables in SQL

Status
Not open for further replies.

Tronsliver

Technical User
Sep 19, 2000
120
US
I'm new to this. Here is my question. Can I use a variable in an SQL statement? Please look at my code below. I'm trying to insert "y". Can this be done?

Public Sub AccessionChart(x As Variant)
Dim y As Variant
y = x
Me.MyChart.RowSource = "SELECT Null, y FROM [AccessionsQry]"
Me!MyChart.charttitle.Text = "Accessions"
Me.MyChart.Refresh
End Sub
 
Try this...

Public Sub AccessionChart(x As Variant)

Me.MyChart.RowSource = "SELECT Null, " & x & " FROM [AccessionsQry]"
Me!MyChart.charttitle.Text = "Accessions"
Me.MyChart.Refresh
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top