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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Open A RecordSet Using OpenRecordSet command 2

Status
Not open for further replies.

TripleJHJO

Programmer
Jan 10, 2003
76
US
I am trying to run this piece of code in an Access 2002 database. I keep getting a "Type Mismatch" error on the Set rstlocations line of the code and I am not sure why. Can anyone advise?

Thanks,

J. Jensen

Code:
Private Sub cmdCopySigs_Click()
    'copy signatures from first record to 2nd and 3rd records
    Dim dbsCurrent As Data
    Dim rstLocations As Recordset
    Dim sigBytes() As Byte
    Dim lFieldsize As Long
    Dim SQL As String

    'get signature BLOB data into sigBytes var
    Set rstLocations = CurrentDb.OpenRecordset("Zinger")
    rstLocations.MoveFirst
    lFieldsize = rstLocations.Fields("Signature").DefinedSize
    ReDim sigBytes(lFieldsize)
    sigBytes = rstLocations.Fields("Signature").GetChunk(lFieldsize)

    'copy sigBytes data into 2nd and 3rd records signature fields
    rstLocations.MoveNext
    While Not rstLocations.EOF
 '       rstLocations.Edit
        rstLocations.Fields("Signature").AppendChunk (sigBytes)
        rstLocations.Update
        rstLocations.MoveNext
    Wend
    rstLocations.Close
End Sub
 
Replace this:
Dim rstLocations As Recordset
with this:
Dim rstLocations As DAO.Recordset

Check in the menu Tools -> References ... that the Microsoft DAO x.y Object Library is ticked.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The declarations (probably)

[tt] Dim dbsCurrent As DAO.Database
Dim rstLocations As DAO.Recordset

' and probably, the following, but your code should do
Set dbsCurrent = CurrentDB
Set rstLocations = dbsCurrent.OpenRecordset("Zinger")[/tt]

Roy-Vidar
 
Thank you.
The reference is what I was missing. Once included - no issues.

J. Jensen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top