Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I did see the first image showing table relationships. The second image is not something I am familiar with. It appears to be showing associated table adapter objects/properties/whatever. So query does not 'reside' in table, table is simply used within a query. Symantics

    Code maybe something like:


    Code:
    strSQL = "SELECT tblSourceMaster.intSiTechID, tblSourceMaster.strVendorName,tblSourceMaster.strVendorID " & _
         "FROM ((lnkItemVendor " & _
         "INNER JOIN tblItemMaster ON tblItemMaster.intSiTechID = lnkItemVendor.intSiTechItemID) " & _
         "INNER JOIN tblSourceMaster ON tblSourceMaster.intSiTechID = lnkItemVendor.intSiTechVendorID) " & _
         "WHERE (lnkItemVendor.intSiTechItemID = " & Me!intSiTechID
    Using cmd As New OleDbCommand With {.Connection = cn}
    cmd.CommandText = strSQL
    At least I would construct SQL statement referencing form control/field for dynamic input like that in VBA.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  2. #17
    gwboolean is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    65
    June,

    The second image is from the dataset. The dataset is not the actual database, but is a set of tableadapters that are created at runtime from the database and is used by Visual Basic. However, the database is updated from the dataset in real time as the dataset is used. The updates are carried out using a bindingsourceEndEdit() and tableadapterUpDate() commands. Please don't ask me how all that comes together and works as I have no idea.

    The queries, as I am currently using them, do indeed reside in the tables (table adapters) contained in the dataset. Each query is written into the a tableadapter and called from the code of an event, routine or function of a form class, as shown above. As you stated, symantics.

    Now, to your code. Is the code you provided above something that is written directly into the code in place of the query call that I have been using? If so, I would like to talk more about this as I would very much like to eliminate the use of writing queries into the tableadapters then calling them from my code, and instead have the query reside in the code where I want to use it.

    I can see three problems for me with what you have. There is no End Using (where would that go for this? Probably after the cmd.CommandText line?). Secondly I already know that I will get an error with the oleDBCommand, although I think that will fix for me by making it Oledb.OleDBCommand. Lastly, where does cn dome from. It is undeclared.

    Let me know, as I am very interested in coding my queries directly into the form events/routines/functions.

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Those two lines (slightly modified for the strSQL variable, may or may not be correct) are from your post so I don't know where you declare and set cn. Your example didn't show the End Using so I was not aware it was required, but yes I expect it would follow the cmd line.

    Not having done database coding in VB.Net or VB6 - I have only adapted some VB6 code to VBA and used some VB6 books to help me learn VBA and run a couple of VB6 non-db apps - can't really offer more. Build an SQL statement string and use it where you see fit.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 05-10-2017, 12:43 AM
  2. Junction Table Help
    By blkane in forum Database Design
    Replies: 5
    Last Post: 10-19-2014, 11:58 AM
  3. Junction Table\
    By Akitt23 in forum Access
    Replies: 5
    Last Post: 11-15-2013, 12:22 PM
  4. Junction Table
    By troachjr in forum Database Design
    Replies: 1
    Last Post: 03-08-2013, 02:10 AM
  5. Junction Table
    By snowboarder234 in forum Access
    Replies: 11
    Last Post: 04-18-2012, 09:31 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums