Recordset - Right or Wrong?

M

Malcolm Potter

One of the data entry forms (frmMatchDataEntry) that I have built in an
Access 2002 database is tied to an underlying table (tblMatchResults). I now
need to carry out, what is for me, some fairly sophisticated processing on a
copy of the data contained in that table. Following some reading I have
attempted to set up a recordset, using the ADO library, without success. For
a start, am I heading in the right direction? The plan is that, after
entering a new set of data I will use a button on the form to run a
procedure, which is only partly developed at the present time. This
'skeleton' procedure stops after only a few lines of code (see below),
giving the message 'Run-time error '13': Type mismatch



Private Sub btnRunMatchProcessingProcedure_Click()



Dim cnn As Connection

Dim MatchRecordSet As New ADODB.Recordset

Dim RowNum As Integer

Dim RecordCount As Integer

Dim Player As String

Dim PlayersBand As String



Set cnn = CurrentProject.Connection



I am fairly new to VBA so any help will be gratefully received.



Regards



Malcolm
 
S

Scott McDaniel

You must also set you connection object to a New instance:

Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset

Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset

You should also disambigulate your objects, as I did above, and should avoid
using the New keyword in your Dim statement (performance issues).
 
M

Malcolm Potter

Scott

Thanks for you help. It did the trick to the point that my 'skeleton'
procedure is now starting to perform.

Regards

Malcolm
 

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