Passing ADO Recordset into a Sub procedure

J

JDB

Good Morning from San Diego

I am trying to learn ADO.

I have 2 tables, one to read from, one to write to (Something a simple
query and append will not solve)

I have stripped out the code to the simpliest from I can.

When i call "AddNewRecord(recWrite,strUPC,strMax)" I get a type
mismatch error.

Thanks for any help.

JDB

Here is my code;
------------------------------------------
Option Compare Database
Option Explicit

Private Sub angela()

Dim i As Integer
Dim strUPC As String
Dim strMax As Double

Dim connRead As ADODB.Connection
Dim recRead As ADODB.Recordset
Set recRead = New ADODB.Recordset
Set connRead = CurrentProject.Connection
recRead.Open "tblRead", connRead, adOpenForwardOnly, adLockReadOnly,
adCmdTableDirect

Dim connWrite As ADODB.Connection
Dim recWrite As ADODB.Recordset
Set recWrite = New ADODB.Recordset
Set connWrite = CurrentProject.Connection
recWrite.Open "tblWrite", connWrite, adOpenForwardOnly,
adLockPessimistic, adCmdTableDirect

'Create new record
For i = 1 To 6

strUPC = recRead!YA
strMax = recRead!MaxLoin
Call AddNewRecord(recWrite, strUPC, strMax)
Next i

End Sub
-------------------------
Sub AddNewRecord(ByVal recWrite As Recordset, strUPC As String, strMax
As Double)
With recWrite
.AddNew
!UPC = strUPC
!Max = strMax
.Update
End With
End Sub
 
J

JDB

Apparently my error is that I did not completely qualify my recordset
by using ADODB

After it was qualified it worked.

Sorry for any bother.

JDB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top