invalid outside procedure when creating a rs

G

Guest

Option Compare Database
Option Explicit

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "Select * from HSIRouterImport", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic

I can't compile the above code. I have Active X Data Objects 2.1 checked in
the reference libraries. Why does it think it is an outside procedure?

What I'm trying to do is convert a VBA for Excel script to an Access script
so I'm trying to open the table first then remove all the spaces from the
data column. I imported an Excel sheet to Access and I need to scrub the
data in Access instead of Excel. Should I change the sheet objects to
AcTable objects?

This is my excel code:

Sub cleanTextInColumn()
Dim C As Range
On Error Resume Next
With ActiveWorkbook
Set C = Worksheets("Port History").Columns("L")
c.Replace What:=" " Replacement:="" SearchOrder:=xlByColumns

On Error GoTo 0
End With
End Sub
tia,
 
D

Douglas J. Steele

As the error is trying to tell you, you must put that code inside a sub or
function which you then call somehow.
 
G

Guest

Thanks, I guess I didn't hit the new button to create the new sub procedure
first. In any case, now it says
 

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