<?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 Get Data from MS Access Database and Fill Result to Selected Column with same Row in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/get-data-from-ms-access-database-and-fill-result-to-selected/m-p/11375430#M141681</link>
    <description>&lt;P&gt;Dears,&lt;BR /&gt;I'm trying working with MS Access Database with iLogic. At the moment I can connect to database, I can get the data but I can't take the result to selected column with same row with lookup cell's value. Please help me. Here my code that I run when working with opened excel file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Read()
    Dim cn As Object, rst As Object
    Set cn = CreateObject("ADODB.Connection")
    Set rst = CreateObject("ADODB.Recordset")
    With cn
        .Provider = "Microsoft.ACE.OLEDB.12.0;"
        .ConnectionString = "Data Source=E:\Database.accdb;Persist Security Info=False;"
        .Open
    End With
    Dim strQuery As String
    Dim oCODE As String
    Dim oCELL As String
    Dim oRCELL As String
    For Each i In Range("A20:J30").Rows
        oCELL = i.Cells(1, 1).Value
        oRCELL = i.Cells(1, 9).Address
        If Left(oCELL, 3) = "000" Then
            oCODE = "000CODE"
        End If
        On Error Resume Next
        strQuery = "SELECT [WEIGHT] FROM " &amp;amp; oCODE &amp;amp; " WHERE [CODE]='" &amp;amp; oCELL &amp;amp; "'"
        rst.Open strQuery, cn
            Sheets("BOM").Range(oRCELL).CopyFromRecordset rst
        rst.Close
        cn.Close
    Next
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Range to check and get data from database is &lt;STRONG&gt;A20:A30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Range to return result that I want is &lt;STRONG&gt;J20:J30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Ref:&lt;BR /&gt;&lt;A href="https://adndevblog.typepad.com/manufacturing/2017/08/connecting-microsoft-access-via-inventor-ilogic.html" target="_blank"&gt;https://adndevblog.typepad.com/manufacturing/2017/08/connecting-microsoft-access-via-inventor-ilogic.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/read-retrieve-information-from-a-ms-access-database-using-ilogic/m-p/3696412#M40978" target="_blank"&gt;https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/read-retrieve-information-from-a-ms-access-database-using-ilogic/m-p/3696412#M40978&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/how-to-connect-to-ms-access-database-from-ilogic/td-p/3612814" target="_blank"&gt;https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/how-to-connect-to-ms-access-database-from-ilogic/td-p/3612814&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Please help me what wrong in my code. And give me the solution. Thanks you very much!&lt;/P&gt;</description>
    <pubDate>Tue, 23 Aug 2022 11:25:54 GMT</pubDate>
    <dc:creator>ngnam1988</dc:creator>
    <dc:date>2022-08-23T11:25:54Z</dc:date>
    <item>
      <title>Get Data from MS Access Database and Fill Result to Selected Column with same Row</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/get-data-from-ms-access-database-and-fill-result-to-selected/m-p/11375430#M141681</link>
      <description>&lt;P&gt;Dears,&lt;BR /&gt;I'm trying working with MS Access Database with iLogic. At the moment I can connect to database, I can get the data but I can't take the result to selected column with same row with lookup cell's value. Please help me. Here my code that I run when working with opened excel file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Read()
    Dim cn As Object, rst As Object
    Set cn = CreateObject("ADODB.Connection")
    Set rst = CreateObject("ADODB.Recordset")
    With cn
        .Provider = "Microsoft.ACE.OLEDB.12.0;"
        .ConnectionString = "Data Source=E:\Database.accdb;Persist Security Info=False;"
        .Open
    End With
    Dim strQuery As String
    Dim oCODE As String
    Dim oCELL As String
    Dim oRCELL As String
    For Each i In Range("A20:J30").Rows
        oCELL = i.Cells(1, 1).Value
        oRCELL = i.Cells(1, 9).Address
        If Left(oCELL, 3) = "000" Then
            oCODE = "000CODE"
        End If
        On Error Resume Next
        strQuery = "SELECT [WEIGHT] FROM " &amp;amp; oCODE &amp;amp; " WHERE [CODE]='" &amp;amp; oCELL &amp;amp; "'"
        rst.Open strQuery, cn
            Sheets("BOM").Range(oRCELL).CopyFromRecordset rst
        rst.Close
        cn.Close
    Next
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Range to check and get data from database is &lt;STRONG&gt;A20:A30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Range to return result that I want is &lt;STRONG&gt;J20:J30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Ref:&lt;BR /&gt;&lt;A href="https://adndevblog.typepad.com/manufacturing/2017/08/connecting-microsoft-access-via-inventor-ilogic.html" target="_blank"&gt;https://adndevblog.typepad.com/manufacturing/2017/08/connecting-microsoft-access-via-inventor-ilogic.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/read-retrieve-information-from-a-ms-access-database-using-ilogic/m-p/3696412#M40978" target="_blank"&gt;https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/read-retrieve-information-from-a-ms-access-database-using-ilogic/m-p/3696412#M40978&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/how-to-connect-to-ms-access-database-from-ilogic/td-p/3612814" target="_blank"&gt;https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/how-to-connect-to-ms-access-database-from-ilogic/td-p/3612814&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Please help me what wrong in my code. And give me the solution. Thanks you very much!&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 11:25:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/get-data-from-ms-access-database-and-fill-result-to-selected/m-p/11375430#M141681</guid>
      <dc:creator>ngnam1988</dc:creator>
      <dc:date>2022-08-23T11:25:54Z</dc:date>
    </item>
  </channel>
</rss>

