compile error : data type mismatch

L

Lucky Girl

i want to modularize database connectivity code so as to re use it later so
i've created a class module for database connectivity functionality.
my database class module code goes as follows

Option Explicit

Function dbconnect()

Dim conn As ADODB.Connection

'creating the database connection
Set conn = New ADODB.Connection
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=D:\My Documents\PMB
files\CorporateFinanceSystem\main.mdb;"

dbconnect = conn

End Function

Function addUser(myconn As ADODB.Connection)

'Set rs = New ADODB.Recordset

'rs.Open "Employee_Details", myconn, adOpenKeyset, adLockOptimistic

'With rs
' .AddNew
' .Fields("Name") = "Mayukha"
' .Fields("Address") = "Pannipitiya"
' .Update
'End With

End Function

the code i call it with goes as follows

Option Explicit

Sub btnAdd_Click()

Dim mydb As Database
Dim myconn As ADODB.Connection

Set mydb = New Database
Set myconn = New ADODB.Connection

myconn = mydb.dbconnect()

mydb.addUser (myconn)



End Sub


but i get an error saying compile error : data type mismatch in the '
mydb.addUser (myconn)' line. i'm a complete beginner to VBA and can't figure
out what i'm doing wrong. can someone please help?
 
P

Pesach Shelnitz

Hi,

See my response to this question in the Word.VBAGeneralQuestions newsgroup.
 

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