I have a query whose result is a single value like sum of cost's column. Can I save the result in a string or a double variable. I tried using recordset. The code I used is as follows:
The message box is not giving any value. I think the problem is in the "Like" clause. Can somebody please help me with this. I am getting an answer if I am omitting the "Like" clause.
Thank you.
Code:
Sub CreateRecordset2()
Dim rst As New ADODB.Recordset
Dim str As String
Dim str1 As String
Dim intgr As Double
str1 = "'*' & 'drilling' & '*'"
rst.Open "SELECT Sum([QUESTOR Run tbl].[cost]) FROM [Project info Tbl] INNER JOIN [QUESTOR Run tbl] ON [Project info Tbl].[Project ID] = [QUESTOR Run tbl].[Project ID] WHERE ((([Project info Tbl].[Offshore only])=Yes) AND (([QUESTOR Run tbl].[QUE$TOR Version Name])='7.3') AND (([QUESTOR Run tbl].[Cost Tab]) Like " & str1 & "))", CurrentProject.Connection
str = rst.GetString
'intgr = CDbl(str)
MsgBox str
'Debug.Print rst.GetString
rst.Close
Set rst = Nothing
End Sub
Thank you.
Comment