How to save the results of my select statement in a variable?

My code is still. The last line gives me a compilation error: "expected end of statement".

Dim strSql As String Dim groupId As String strSql = "Select ID from RevenueGroup where description = '" & ListO.Value & "'" groupId = CurrentProject.Connection.Execute strSql 
+4
source share
1 answer

You look at something like this

 Dim strSql As String Dim groupId As String strSql = "Select ID from RevenueGroup where description = '" & ListO.Value & "'" Dim rec As Recordset set rec= CurrentProject.Connection.Execute strSql groupId = rec(0) 

You need to set the query results to the recordset, and then derive the first value from its results. Without all the specific variable, I cannot compile it completely, but it should be a good template to start with.

+4
source

Source: https://habr.com/ru/post/1302515/


All Articles