Jump to content

Recommended Posts

Posted

I have a VBA code loaded in AutoCad. In this code I connect to a database (access) to store data from 3dpolylines in the drawing. In this process I want to check the new selected line with the first and the last entry of the database (so i can add the selected lines to the line stored in the database).

 

For this i make a record set of the database to figure out what the size is. This wount work as is should be!!

 

    SQL = "SELECT Nr FROM Polyline"
   Set rsline = DB.Execute(SQL)
   MsgBox rsline.RecordCount
   rsline.MoveLast

 

The rsline.recordCount gives a value -1

And the movelast command gives ann error. Automation error (Error 440)

 

(It apears that only the rsline.movenext works properly. So i can write a loop with rsline.movenext until rsline.eof = true, but this database will be quite large so I don't prefer this option.)

 

Can someone give me a clue on how i can tackle this problem

Posted

This one worked for me:

 

Option Compare Database
Option Explicit

Sub test()

Dim rsline As DAO.Recordset
Dim Db As DAO.Database
Set Db = CurrentDb
Dim SQL As String
   SQL = "SELECT Nr FROM Polyline"
   Set rsline = Db.OpenRecordset(SQL)
   MsgBox "Number of records are: " & rsline.RecordCount
   rsline.MoveLast
   MsgBox "Polyline number is: " & rsline!Nr
   ' close and clean up 'rsline' and 'Db' here if you need it

End Sub

 

~'J'~

Posted

The problem was that I used an ADO database and not a DAO now i changed that the problem is gone. Thanks for the advise

Posted

I am glad you have solved a problem

Cheers :)

 

~'J'~

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...