Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't open a query

Status
Not open for further replies.

tsp120

Programmer
May 21, 2003
52
US
Hi, I am trying to just simply create and open a query. But for some reason, it won't work, and gives me an error message saying:

Run-time error '91': Object variable or With block variable not set

Below is a bit of the code, and where the error occurs.

Dim objConn As New ADODB.Connection
Dim FindHOBq As String

objConn.Open strConnect

FindHOBq = "SELECT MIN(HOB), AVG(HOB), MAX(HOB) FROM [Ballistic Tests] WHERE ID = 76 GROUP BY [Group]"
FindHOBrs.Open FindHOBq, objConn, adOpenDynamic, adLockReadOnly <---- error occurs here
FindHOBrs.MoveFirst

Does anyone have a clue why this won't open the query? The other queries I have in this report open just fine, but for some reason this one won't.

Thanks, Tim
 
Tim:

I'm not familiar with the format you are using, but from my experience with using recordsets, it looks like you are missing a SET statement.

With databases/recordsets that would be:

Set dbTemp = CurrentDb
Set rsTemp = dbTemp.OpenRecordSet(strSQL)

Hope this helps a bit.

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top