B
Bob Ewers
I'm trying to feed the WHERE portion of an SQL statement with the string stPMname. The string takes it's value from an option group result. My date variables work fine, but the string variable is treated like a parameter by SQL. See code below for reference. Can anyone suggest a solution.
Also, is there a way to have an option group return zero instead of null if there is no selection.
Private Sub PMFrame_AfterUpdate()
Dim intPMvar As Integer
Dim stPMname As String
Dim SQLstmt As String
Dim startdate As Date
Dim EndDate As Date
startdate = Me![startdate]
EndDate = Me![EndDate]
intPMvar = Me![PMFrame]
Select Case intPMvar
Case 1 'Returns xxx Total
stPMname = "xxx"
SQLstmt = "SELECT [%$##@_Alias].pm, Sum([%$##@_Alias].bps) AS SumOfbps FROM [SELECT pm, rpm_date as ddate, bps FROM rpm_data WHERE rpm_date >= startdate AND rpm_date <= enddate UNION SELECT pm, trade_date as ddate, bps FROM trade WHERE trade_date >= startdate AND trade_date <= enddate]. AS [%$##@_Alias] WHERE [%$##@_Alias].pm = stPMname GROUP BY [%$##@_Alias].pm"
PMReturn.RowSource = SQLstmt
PMReturn.Requery
Also, is there a way to have an option group return zero instead of null if there is no selection.
Private Sub PMFrame_AfterUpdate()
Dim intPMvar As Integer
Dim stPMname As String
Dim SQLstmt As String
Dim startdate As Date
Dim EndDate As Date
startdate = Me![startdate]
EndDate = Me![EndDate]
intPMvar = Me![PMFrame]
Select Case intPMvar
Case 1 'Returns xxx Total
stPMname = "xxx"
SQLstmt = "SELECT [%$##@_Alias].pm, Sum([%$##@_Alias].bps) AS SumOfbps FROM [SELECT pm, rpm_date as ddate, bps FROM rpm_data WHERE rpm_date >= startdate AND rpm_date <= enddate UNION SELECT pm, trade_date as ddate, bps FROM trade WHERE trade_date >= startdate AND trade_date <= enddate]. AS [%$##@_Alias] WHERE [%$##@_Alias].pm = stPMname GROUP BY [%$##@_Alias].pm"
PMReturn.RowSource = SQLstmt
PMReturn.Requery