Author Topic: VBA and Databases  (Read 6723 times)

0 Members and 1 Guest are viewing this topic.

M-dub

  • Guest
VBA and Databases
« on: June 22, 2004, 01:06:17 PM »
Hey all,
   I'm trying to follow the tutorial on Afralisp but I'm stuck...I keep getting the error message.  I don't know what he's talking about when he says "(If you have problems when writing or running this projects, ensure that the Microsoft DAO 3.6 Object Library is selected in your VBA References.)".  Which VBA References?  Where?  (stop laughing!)

   I need some help...(as if you hadn't guess that yet!:roll:)...Back to the ol' attribute extraction problem.  I've done some hunting and searching, which led me to Afralisp, but is there some kind soul out there who could give me an added personal touch?   :wink:  :oops:

   I'm looking to go back and forth between AutoCAD blocks and Access / Excel...what should I do?  Where should I look to figure it out on my own?

Thanks folks!

Jeff_M

  • King Gator
  • Posts: 4088
  • C3D user & customizer
Re: VBA and Databases
« Reply #1 on: June 22, 2004, 01:27:56 PM »
Quote from: M-dub
Hey all,
   I'm trying to follow the tutorial on Afralisp but I'm stuck...I keep getting the error message.  I don't know what he's talking about when he says "(If you have problems when writing or running this projects, ensure that the Microsoft DAO 3.6 Object Library is selected in your VBA References.)".  Which VBA References?  Where?  (stop laughing!)
In the VBA IDE go to Tools->References and select the DAO 3.6 reference.

 
Quote
 I need some help...(as if you hadn't guess that yet!:roll:)...Back to the ol' attribute extraction problem.  I've done some hunting and searching, which led me to Afralisp, but is there some kind soul out there who could give me an added personal touch?   :wink:  :oops:
:choke: is that personal enough?  :mrgreen:

Quote
 I'm looking to go back and forth between AutoCAD blocks and Access / Excel...what should I do?  Where should I look to figure it out on my own?
I figured it out from the sample files/projects that came with ACAD and perusing the Adesk newsgroups and www.cadvault.com (formerly vbdesign.net)

Jeff

hendie

  • Guest
VBA and Databases
« Reply #2 on: June 22, 2004, 03:31:03 PM »
one problem area is getting the connection string right... have you managed to connect to the database successfully ?
isn't there a different dao version dependant upon which version of Acad you're using  ~ I can't remember.

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
Re: VBA and Databases
« Reply #3 on: June 22, 2004, 03:33:42 PM »
Quote from: M-dub
Hey all,
   I'm trying to follow the tutorial on Afralisp but I'm stuck...I keep getting the error message.  I don't know what he's talking about when he says "(If you have problems when writing or running this projects, ensure that the Microsoft DAO 3.6 Object Library is selected in your VBA References.)".  Which VBA References?  Where?  (stop laughing!)

   I need some help...(as if you hadn't guess that yet!:roll:)...Back to the ol' attribute extraction problem.  I've done some hunting and searching, which led me to Afralisp, but is there some kind soul out there who could give me an added personal touch?   :wink:  :oops:

   I'm looking to go back and forth between AutoCAD blocks and Access / Excel...what should I do?  Where should I look to figure it out on my own?

Thanks folks!


M-dub,

Why not ask Kenny Ramage, after all he is the guy that wrote the tutorial?
I drink beer and I know things....

M-dub

  • Guest
VBA and Databases
« Reply #4 on: June 22, 2004, 03:38:10 PM »
I kinda sorta got it working...
They've got a little VB course going on once a week at the office, so that, I'm sure, will help.  I think that if I'm eventually able to figure out how to do it, I'll find all kinds of uses around here.

hendie

  • Guest
VBA and Databases
« Reply #5 on: June 22, 2004, 03:41:10 PM »
Mike, if you can hold on until tomorrow, I can send you some stuff that I use to connect Acad & Access ~ it should sort of get you on the right track

though it would help if you could be just a little bit more specific about the errors you're getting

M-dub

  • Guest
VBA and Databases
« Reply #6 on: June 22, 2004, 03:57:09 PM »
Thanks a lot, Hendie!
When I follow the tutorial, I always get the alert "Cannot find TBlock2000.dvb - Call Supervisor." but when I hit Alt+F11 and change some paths, it seems to work fine.  I think I'm going to work from there, but I'll have to figure out how to get FROM access TO AutoCAD....tomorrow.
Thanks Hendie ;)

hendie

  • Guest
VBA and Databases
« Reply #7 on: June 23, 2004, 07:26:16 AM »
are all the files definitely in your Acad support path ?

M-dub

  • Guest
VBA and Databases
« Reply #8 on: June 23, 2004, 07:45:16 AM »
100% completely sure.  I put them in SUPPORT when it wasn't working in the directory I had them in in the first place.  I had mapped the new directory, but it didn't work so I tried the Support directory...I don't know why it wasn't working...

hendie

  • Guest
VBA and Databases
« Reply #9 on: June 23, 2004, 08:12:35 AM »
Mike, I'm getting the same errors as you. It won't find the mdb unless it is hard coded, also, there is no check to see if the selection set already exists and it throws a wobbly.

Try hard coding the database location in there & save the dvb.
Code: [Select]
Set dbInfo = OpenDatabase("C:\mypathinfo\titleblocks\TBLOCK.MDB")

and add this to the beginning of the Userform ~Initialise event
Code: [Select]
Set SSetCol = ThisDrawing.SelectionSets
             For Each ssnew In SSetCol
                 If ssnew.Name = "TBLK" Then
                 ThisDrawing.SelectionSets.Item("TBLK").Delete
             Exit For
             End If
         Next

that will delete any existing selection sets of the same name when starting up the routine.

M-dub

  • Guest
VBA and Databases
« Reply #10 on: June 23, 2004, 09:24:37 AM »
Thanks Hendie,
   I did all that stuff, but I'm still getting the errors.  It works fine if I run it from the VB environment, but ALWAYS get the error if I just type tblock2000 at the command prompt...
Any other ideas?

hendie

  • Guest
VBA and Databases
« Reply #11 on: June 23, 2004, 09:39:53 AM »
open the lisp and change
Code: [Select]
(setq f (findfile "tblock.dvb"))

to
Code: [Select]

(setq f (findfile "tblock2000.dvb"))


***EDITED***

and I still got errors... so try changing
Code: [Select]
(vl-vbaload "tblock2000.dvb")
to
Code: [Select]

(vl-vbaload f)

and it should run

M-dub

  • Guest
VBA and Databases
« Reply #12 on: June 23, 2004, 11:24:11 AM »
Hendie, you're bloody brilliant!

Thanks a million!

I can now hack this to bits and see how I can use it for our own application.  Hopefully after our little course is over, I'll become a major player in this particular forum.  I have seen many many uses for VB in my position where I am right now so I'll likely be in here getting (and hopefully GIVING) help far more frequently.

Thanks again, Hendie...Greatly Appreciated!
Mike