A family of Microsoft relational database management systems designed for ease of use.
I did find my answer in another web site.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In CreateBloom I create and populate a table (BloomArt) with a select statement. This works great
'-----------------------------
Public Sub CreateBloom()
'---------------------------------
Set db = CurrentDb
Dim BloomArt As Recordset
Dim StringSQL As String ' Not used
Dim BAString As String ' Not used
Dim strSQL As String ' used to create BloomArt data.
strSQL = "SELECT [ArtworkName],[ArtistName],[Venue] into BloomArt FROM [ArtworkInfoIdx] WHERE ((([Venue])='BloomArt'))"
DoCmd.RunSQL (strSQL)
rs.Close
End Sub ' end CreateBloom
Next I want to read through the table and loop through the records and I get a type mismatch at the OpenRecordset. Confused!
'----------------------
Public Sub BloomLoop()
'----------------------
Dim rs As Recordset
Dim BloomArt As Recordset
Set rs = CurrentDb.OpenRecordset("BloomArt") 'type mismatch
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do Until rs.EOF = True
rs.MoveNext
Loop
Else
MsgBox "there are no records in the recordset"
End If
MsgBox "Finished looping through records."
rs.Close 'Close the recordset
Set rs = Nothing 'Clean up
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
I did find my answer in another web site.
I have tried a lot of things, I don't understand why I didn't seem to need the DAO with the recordset in "CreateBloom ".
Your CreateBloom procedure doesn't ever actually create a recordset; it just executes a SQL statement. You don't need the declaration of BloomArt in that procedure at all.
Select Tools > References in the Visual Basic Editor.
Scroll down the list of references.
Tick the check box for 'Microsoft Office 14.0 Access database engine Object Library'.
Click OK.
Try Debug > Compile … (there will be a name instead of …) to see if the code compiles now.
There are 2 types of recordsets: ADODB and DAO. With CurrentDb, you need to use the DAO type. To make this explicit, change the line
Dim BloomArt As Recordset
to
Dim BloomArt As DAO.Recordset
I changed to "Dim BloomArt As DAO.Recordset" Now I get "User-defined type not defined" I have tried a lot of things, I don't understand why I didn't seem to need the DAO with the recordset in "CreateBloom ".
It seems like any time I try to use DAO it seems to come up with syntax error (compile error) and if I don't use it I get the Mismatch runtime error.
It seems that I must have to do something on a higher level to be able to set he dao, but I am new to doing this in Access. I am usually a VB programmer.
There are 2 types of recordsets: ADODB and DAO. With CurrentDb, you need to use the DAO type. To make this explicit, change the line
Dim BloomArt As Recordset
to
Dim BloomArt As DAO.Recordset