<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Check blocknames against database in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/check-blocknames-against-database/m-p/2159493#M21609</link>
    <description>Here is a quick example how to connect&lt;BR /&gt;
to database and match block names&lt;BR /&gt;
if you have the array of these blocks&lt;BR /&gt;
&lt;BR /&gt;
' request reference to: Microsoft ActiveX Data Object 2.X Library&lt;BR /&gt;
Sub CompBlockNames()&lt;BR /&gt;
     On Error GoTo ErrorHandler&lt;BR /&gt;
&lt;BR /&gt;
     ' connection and recordset variables&lt;BR /&gt;
     Dim conn As ADODB.connection&lt;BR /&gt;
     Dim rst As ADODB.Recordset&lt;BR /&gt;
     Dim sqlStr As String&lt;BR /&gt;
&lt;BR /&gt;
     ' open connection&lt;BR /&gt;
     Set conn = New ADODB.connection&lt;BR /&gt;
     With conn&lt;BR /&gt;
          .Provider = "Microsoft.Jet.OLEDB.4.0"&lt;BR /&gt;
          .Properties("Data Source") = "C:\Temp\Test.mdb" '&amp;lt;--full path to database file&lt;BR /&gt;
          .Open&lt;BR /&gt;
     End With&lt;BR /&gt;
&lt;BR /&gt;
     ' open recordset&lt;BR /&gt;
     Set rst = New ADODB.Recordset&lt;BR /&gt;
     rst.CursorLocation = adUseClient&lt;BR /&gt;
     ' change the table name to your suit (I use MyTable)&lt;BR /&gt;
     sqlStr = "SELECT MyTable.blockname FROM MyTable" '&amp;lt;-- blockname is field name in this table&lt;BR /&gt;
     rst.Open sqlStr, conn, adOpenStatic, adLockReadOnly, adCmdText&lt;BR /&gt;
     &lt;BR /&gt;
     Dim ar As Variant&lt;BR /&gt;
     'say here is a list of block names:&lt;BR /&gt;
     ar = Array("a", "b", "c", "d", "e", "f", "g", "h")&lt;BR /&gt;
     &lt;BR /&gt;
     Dim i As Integer&lt;BR /&gt;
     Dim col As New Collection&lt;BR /&gt;
     &lt;BR /&gt;
     For i = 0 To UBound(ar)&lt;BR /&gt;
          rst.MoveFirst&lt;BR /&gt;
          Do While Not rst.EOF&lt;BR /&gt;
               If rst!blockname = ar(i) Then '&amp;lt;-- if the match have found then collect it&lt;BR /&gt;
                    col.Add ar(i)&lt;BR /&gt;
               End If&lt;BR /&gt;
               rst.MoveNext&lt;BR /&gt;
          Loop&lt;BR /&gt;
     Next&lt;BR /&gt;
     Dim vr As Variant&lt;BR /&gt;
     For Each vr In col&lt;BR /&gt;
          Debug.Print vr&lt;BR /&gt;
     Next&lt;BR /&gt;
     ' clean up&lt;BR /&gt;
     rst.Close&lt;BR /&gt;
     conn.Close&lt;BR /&gt;
     Set rst = Nothing&lt;BR /&gt;
     Set conn = Nothing&lt;BR /&gt;
     Exit Sub&lt;BR /&gt;
&lt;BR /&gt;
ErrorHandler:&lt;BR /&gt;
&lt;BR /&gt;
     If Err &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;
          MsgBox Err.Source &amp;amp; " --&amp;gt; " &amp;amp; Err.Description, , "Error"&lt;BR /&gt;
     End If&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
    <pubDate>Sat, 19 Jan 2008 23:40:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-01-19T23:40:38Z</dc:date>
    <item>
      <title>Check blocknames against database</title>
      <link>https://forums.autodesk.com/t5/vba-forum/check-blocknames-against-database/m-p/2159490#M21606</link>
      <description>Hello&lt;BR /&gt;
I have a database of blocknames. Is there a way to check if the blocks in a drawing exist in my database?&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Fri, 18 Jan 2008 18:40:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/check-blocknames-against-database/m-p/2159490#M21606</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-18T18:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Check blocknames against database</title>
      <link>https://forums.autodesk.com/t5/vba-forum/check-blocknames-against-database/m-p/2159491#M21607</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Yes&lt;BR /&gt;
&lt;BR /&gt;
Look at the ADO tools.&lt;BR /&gt;
&lt;BR /&gt;
Also, clarify in your mind whether you want to check if "Blocks" are in the &lt;BR /&gt;
drawing database or "BlockReferences" are in the drawing.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
Laurie Comerford&lt;BR /&gt;
&lt;MB77&gt; wrote in message news:5824653@discussion.autodesk.com...&lt;BR /&gt;
Hello&lt;BR /&gt;
I have a database of blocknames. Is there a way to check if the blocks in a &lt;BR /&gt;
drawing exist in my database?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;/MB77&gt;</description>
      <pubDate>Fri, 18 Jan 2008 21:19:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/check-blocknames-against-database/m-p/2159491#M21607</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-18T21:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Check blocknames against database</title>
      <link>https://forums.autodesk.com/t5/vba-forum/check-blocknames-against-database/m-p/2159492#M21608</link>
      <description>since the blockrefs are merely "copies" of the block definition what &lt;BR /&gt;
difference would it make?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"Laurie Comerford" &lt;LAURIE.COMERFORD&gt; wrote in message &lt;BR /&gt;
news:5824849@discussion.autodesk.com...&lt;BR /&gt;
Hi,&lt;BR /&gt;
&lt;BR /&gt;
Yes&lt;BR /&gt;
&lt;BR /&gt;
Look at the ADO tools.&lt;BR /&gt;
&lt;BR /&gt;
Also, clarify in your mind whether you want to check if "Blocks" are in the&lt;BR /&gt;
drawing database or "BlockReferences" are in the drawing.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
Laurie Comerford&lt;BR /&gt;
&lt;MB77&gt; wrote in message news:5824653@discussion.autodesk.com...&lt;BR /&gt;
Hello&lt;BR /&gt;
I have a database of blocknames. Is there a way to check if the blocks in a&lt;BR /&gt;
drawing exist in my database?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;/MB77&gt;&lt;/LAURIE.COMERFORD&gt;</description>
      <pubDate>Sat, 19 Jan 2008 16:37:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/check-blocknames-against-database/m-p/2159492#M21608</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-19T16:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Check blocknames against database</title>
      <link>https://forums.autodesk.com/t5/vba-forum/check-blocknames-against-database/m-p/2159493#M21609</link>
      <description>Here is a quick example how to connect&lt;BR /&gt;
to database and match block names&lt;BR /&gt;
if you have the array of these blocks&lt;BR /&gt;
&lt;BR /&gt;
' request reference to: Microsoft ActiveX Data Object 2.X Library&lt;BR /&gt;
Sub CompBlockNames()&lt;BR /&gt;
     On Error GoTo ErrorHandler&lt;BR /&gt;
&lt;BR /&gt;
     ' connection and recordset variables&lt;BR /&gt;
     Dim conn As ADODB.connection&lt;BR /&gt;
     Dim rst As ADODB.Recordset&lt;BR /&gt;
     Dim sqlStr As String&lt;BR /&gt;
&lt;BR /&gt;
     ' open connection&lt;BR /&gt;
     Set conn = New ADODB.connection&lt;BR /&gt;
     With conn&lt;BR /&gt;
          .Provider = "Microsoft.Jet.OLEDB.4.0"&lt;BR /&gt;
          .Properties("Data Source") = "C:\Temp\Test.mdb" '&amp;lt;--full path to database file&lt;BR /&gt;
          .Open&lt;BR /&gt;
     End With&lt;BR /&gt;
&lt;BR /&gt;
     ' open recordset&lt;BR /&gt;
     Set rst = New ADODB.Recordset&lt;BR /&gt;
     rst.CursorLocation = adUseClient&lt;BR /&gt;
     ' change the table name to your suit (I use MyTable)&lt;BR /&gt;
     sqlStr = "SELECT MyTable.blockname FROM MyTable" '&amp;lt;-- blockname is field name in this table&lt;BR /&gt;
     rst.Open sqlStr, conn, adOpenStatic, adLockReadOnly, adCmdText&lt;BR /&gt;
     &lt;BR /&gt;
     Dim ar As Variant&lt;BR /&gt;
     'say here is a list of block names:&lt;BR /&gt;
     ar = Array("a", "b", "c", "d", "e", "f", "g", "h")&lt;BR /&gt;
     &lt;BR /&gt;
     Dim i As Integer&lt;BR /&gt;
     Dim col As New Collection&lt;BR /&gt;
     &lt;BR /&gt;
     For i = 0 To UBound(ar)&lt;BR /&gt;
          rst.MoveFirst&lt;BR /&gt;
          Do While Not rst.EOF&lt;BR /&gt;
               If rst!blockname = ar(i) Then '&amp;lt;-- if the match have found then collect it&lt;BR /&gt;
                    col.Add ar(i)&lt;BR /&gt;
               End If&lt;BR /&gt;
               rst.MoveNext&lt;BR /&gt;
          Loop&lt;BR /&gt;
     Next&lt;BR /&gt;
     Dim vr As Variant&lt;BR /&gt;
     For Each vr In col&lt;BR /&gt;
          Debug.Print vr&lt;BR /&gt;
     Next&lt;BR /&gt;
     ' clean up&lt;BR /&gt;
     rst.Close&lt;BR /&gt;
     conn.Close&lt;BR /&gt;
     Set rst = Nothing&lt;BR /&gt;
     Set conn = Nothing&lt;BR /&gt;
     Exit Sub&lt;BR /&gt;
&lt;BR /&gt;
ErrorHandler:&lt;BR /&gt;
&lt;BR /&gt;
     If Err &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;
          MsgBox Err.Source &amp;amp; " --&amp;gt; " &amp;amp; Err.Description, , "Error"&lt;BR /&gt;
     End If&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
      <pubDate>Sat, 19 Jan 2008 23:40:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/check-blocknames-against-database/m-p/2159493#M21609</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-19T23:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: Check blocknames against database</title>
      <link>https://forums.autodesk.com/t5/vba-forum/check-blocknames-against-database/m-p/2159494#M21610</link>
      <description>"Steve" wrote:&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt;&amp;gt; since the blockrefs are merely "copies" of the block definition &lt;BR /&gt;
&lt;BR /&gt;
blockrefs are not 'merely copies' of a block definition.&lt;BR /&gt;
&lt;BR /&gt;
BlockReferences often represent real-world things that&lt;BR /&gt;
exist in a design. The presence of a block definition alone&lt;BR /&gt;
doesn't mean that what it represence exists in a design,&lt;BR /&gt;
which is only the case if there are references.&lt;BR /&gt;
&lt;BR /&gt;
Which the OP is actually looking for depends on what&lt;BR /&gt;
he's doing. &lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com</description>
      <pubDate>Sun, 20 Jan 2008 14:29:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/check-blocknames-against-database/m-p/2159494#M21610</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-20T14:29:48Z</dc:date>
    </item>
  </channel>
</rss>

