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
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