Am trying to write a MSSQL query via a Excel2003 macro in VB.
I am doing the below query to SUM(A.NO) value in a table A. This works fine until its gets more complicated and I am doing a JOIN and I need to specify 2 variables for the WHERE statement as shown below.
Script to enter value for row identification
Dim sCode As String
sCode = Application.InputBox(Prompt:="Matter Number?", Type:=2)
strSQL = Replace$(sSQL, "zz", sCode)
This works fine.
Now when I join two tables to query a SUM it falls apart as it sums the total values of the table not just the individual value as with the statement below
sqlstring = "Select A.NO
From A, B
Where A.NO = 'zz'
Here is the problem I need to define the NO as "zz" my manual entry via the pop up box and also I need to define NO in both tables A and B. Can someone help me.
Where A.NO = B.NO
Hope that makes sense