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

modifying VB code to work in Access 97

Status
Not open for further replies.

MontyBurns

Programmer
Oct 3, 2001
99
GB
Hi,

I've got the following VB6 code which calls a DLL and returns an ADODB.Recordset. I need to get it to work in an Access 97 DB but can't figure out what I have to do.

Private Sub cmdGetuserInfo_Click()
Dim CCPM As CCPnMObjects.CCPnM
Dim rs As ADODB.Recordset
Dim NTUserID As String

'On Error GoTo err_handler

Set CCPM = CreateObject("CCPnMObjects.CCPnM")
Set rs = CreateObject("adodb.Recordset")

NTUserID = Me.txtUID

CCPM.BindingString = Me.txtBindingString.Text

Set rs = CCPM.getUserInfo(NTUserID)

If Not rs.EOF Then
Me.txtFName = rs("Firstname")
Me.txtSurname = rs("Lastname")
Me.txtPArea = rs("PracticeArea")
Me.txtJobTitle = rs("JobTitle")
Me.txtLocation1 = rs("Location1")
Me.txtLocation2 = rs("location2")
Me.txtEmail = rs("Email")
Me.txtRole = rs("Role")
End If

Set rs = Nothing
Set CCPM = Nothing

Exit Sub
err_handler:
MsgBox Err.Number & " - " & Err.Description
End Sub

I've added a reference to the DLL, but am getting errors with the ADODB.Recordset part. What exactly should I be doing?

Any help much appreciated,
Burns
 
Could you be more specific. What is the error?
Did you create the DLL?
 
I get a type mismatch from the following line:

Set rs = CreateObject("adodb.Recordset")

I'm using Access 97 and therefore DAO. I've tried adding a reference to ADO 2.7 but no luck.

I didn't write the DLL, but basically the .GetUserInfo method takes a domain and user ID, searches a SQL DB, and returns the relavant recordset (obviously only one record/row for each user ID).

My problem is i'm not sure how to define a recordset and fill it with the results from the method.

Any ideas?

Thanks,
Burns
 
Instead of

Set rs = CreateObject("adodb.Recordset")
Set CCPM = CreateObject("CCPnMObjects.CCPnM")

try

Set rs = New ADODB.Recordset
Set CCPM = New CCPnMObjects.CCPnM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top