recordset probs?

spinkung

Registered User.
Local time
Today, 19:59
Joined
Dec 4, 2006
Messages
267
Hi all,

Can anyone see whats wrong with this??????

It's my first recordset attempt and i'm ready to find a long piece of rope and a high beam already.


Code:
Private Sub Form_Load()

Dim dbMyDB As Database
Set dbMyDB = CurrentDb
Dim rsMyRS As Recordset
[COLOR="Red"]Set rsMyRS = dbMyDB.openRecordSet("QRY_StockEntry")[/COLOR]
If Not rsMyRS.EOF Then rsMyRS.MoveFirst
Do While Not rsMyRS.EOF
    lstRecords.AddItem rsMyRS!CNTR
    lstRecords.ItemData(lstRecords.ListIndex) = rsMyRS!StockID
    rsMyRS.MoveNext
Loop

where the text is red I keep getting : runtime error '13': type mismatch


Cheers,
Spinkung. :confused:
 
I seem to remember something similar to this a long time ago.

As I recall, my problem was down to having references set to both DAO and ADODB, and not specifying in code which to use.

For example, I think you should specify that you want to use DAO rather than ADODB when you define your objects such that they read

Dim dbMyDB as DAO.Database
Dim rsMyRS as DAO.Recordset

You will definately have to do this if both references are set in your preferences as by default I think Access uses ADODB.


Hope this helps

W1dge
 
That cracked it, thanks alot for your help.


Spinkung. :rolleyes:
 

Users who are viewing this thread

Back
Top Bottom