Hi,
I am getting an error 424 whenever I'm trying to run the sql query which should filter the data which i have retrieved based on some combo box value. The code snippet looks like this:
Private Sub cmdShowData_Click()
'populate data
Select Case cmbDatagroups.Value
Case "Insight"
strSQL = "SELECT * FROM [Insight$] "
If cmbHLScenarios.Text <> "" Then
If cmbDatagroups.Text <> "" Then
strSQL = strSQL & " WHERE [High Level Scenario]='" & cmbHLScenario.Value & "'"
End If
End If
And the common module is :
Option Explicit
Public cnn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public strSQL As String
Public Sub OpenDB()
If cnn.State = adStateOpen Then cnn.Close
cnn.ConnectionString = "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" & _
ActiveWorkbook.Path & Application.PathSeparator & ActiveWorkbook.Name
cnn.Open
End Sub
Public Sub closeRS()
If rs.State = adStateOpen Then rs.Close
rs.CursorLocation = adUseClient
End Sub
It would be great if anybody can help me sort out this issue.
Many thanks in advance.
Bookmarks