views:

63

answers:

1

My code so far is this. The last line gives me a compile 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  A: 

You are looking at something kinda 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 results of the query to a recordset and then pull the first value from its results. Without all the defined variable, I cannot get this to fully compile but this should be a good template to start from.

JDMX
It is generally better to use DAO with Accesss, so: Set rec=CurrentDB.OpenRecordset(strSQL). You may need to Dim rec As DAO.Recordset
Remou