Can't figure out error message.

R

Robert Johnson

Can some one tell me was would are the possiblies which
would cause this error message, "Object or provider is not
capable of performing requested operation." My provider is
Jet 4. The code stops at: !fldSmallObj = pstrTrans

This is code

Private Sub cmd2DObj_Click()
'On Error GoTo Err_cmd2DObj_Click

Dim connLA2DObj As New ADODB.Connection
Dim prstLA2DObj As New ADODB.Recordset
Dim pstrSQL As String, pstrAgyObj As String
Dim pstrTrans As String

pstrSQL = "SELECT fldAgyObj, fldSmallObj FROM tblTest"

'Makes connection to current project.
Set connLA2DObj = CurrentProject.Connection
prstLA2DObj.Open pstrSQL, connLA2DObj, adOpenKeyset

'Loops through the data base putting two digit objects in
the table.
With prstLA2DObj
Do Until .EOF
pstrAgyObj = !fldAgyObj
pstrTrans = Left(pstrAgyObj, 2)
!fldSmallObj = pstrTrans
.Update
.MoveNext
Loop

'Displays the record count.
txtRecCnt.Text = .RecordCount

'Closes the recordset.
.Close
End With


If Not prstLA2DObj Is Nothing Then Set prstLA2DObj =
Nothing
If Not connLA2DObj Is Nothing Then Set connLA2DObj =
Nothing
End Sub
 
H

HSalim

robert
add
..Edit before your problem line.

You are doing this the long way. All you need is

dim db as database
set db = currentdb
ssql = "UPDATE tblTest SET fldSmallObj = left(fldAgyObj,2)"
db.execute (ssql)

you will also make life so much easier if you use variable names that are
easy to use and understand

so, rather than using connLA2DObj use oConn or ConnObj
if you have multiple connection objects, rather than using Conn1, conn2
you can use cnXXX and cnYYY where XXX and YYY represent the databases you
are connecting to

Keep it simple, easy to type out and easily understandable.

HS
 
V

Van T. Dinh

If you don't specify the LockType, it is defaulted to Read-Only!

Check Access VB Help on the Open (Recordset) Method for the arguments.
 
R

Robert Johnson

Thanks for the code. I have been corresponding with some
on a VB forum and we fixed the my code. Your's is way more
efficient and I will try to substitute your code and see
what happens. What is the complete line of code I would
add before my problem line?
 
R

Robert Johnson

-----Original Message-----
I tried this code I dim ssql as string and ran the code.
I am getting USer defined Type not defined aaadn bd as
database in hightlighted.
 

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