Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. access uniquetable

access uniquetable

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasequestionannouncement
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    C Coudou
    wrote on last edited by
    #1

    Apologize if I post this on the wrong forum. In ACCESS, I have Form Open event that will connect to DB1 and datas will show on the detail records. The form has a Uniquetable = "tableEmp". Now, I have a option button that will change database to DB2, Note: DB1 and DB2 all tables are the same. In the form details I have checkbox, if I will checked the checkbox the tables update automatically, and it will update because of the uniquetable but If I will change the database the tables will not update. what's cause of this? thanks in advance,.

    C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

    A 1 Reply Last reply
    0
    • C C Coudou

      Apologize if I post this on the wrong forum. In ACCESS, I have Form Open event that will connect to DB1 and datas will show on the detail records. The form has a Uniquetable = "tableEmp". Now, I have a option button that will change database to DB2, Note: DB1 and DB2 all tables are the same. In the form details I have checkbox, if I will checked the checkbox the tables update automatically, and it will update because of the uniquetable but If I will change the database the tables will not update. what's cause of this? thanks in advance,.

      C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      Check if the database db2 has the same table. If it does, the primary key that you update the table on may not be present in this table (in the second database).

      C 1 Reply Last reply
      0
      • A Abhinav S

        Check if the database db2 has the same table. If it does, the primary key that you update the table on may not be present in this table (in the second database).

        C Offline
        C Offline
        C Coudou
        wrote on last edited by
        #3

        thanks. i check the db2 and it has the same table. is my approach correct? i mean connecting other database in an access form. here is my snippet code: ACCESS FORM

        'Default database DB1
        Private Sub Form_Open(Cancel As Integer)
        Dim ssql As String

        ssql = "SELECT \[tbl1\].id, \[tbl1\].code,\[tbl1\].mflag, \[tbl2\].cdnum, \[tbl3\].bname"
        ssql = ssql & " FROM  \[tbl1\] INNER JOIN"
        ssql = ssql & " \[tbl2\] ON"
        ssql = ssql & " \[tbl1\].id = \[tbl2\].id INNER JOIN"
        ssql = ssql & " \[tbl3\] ON \[tbl1\].code = \[tbl3\].code"
        ssql = ssql & " WHERE \[tbl1\].mdate ='2011/10/12'"
        Me.RecordSource = ssql
        
        Me.UniqueTable = "tbl2"
        

        End Sub

        'option to select DB1 or DB2
        Private Sub optSel_AfterUpdate()
        Dim ssql As String

        'DB1
        If Me.optSel = 1 Then
            ssql = "SELECT \[tbl1\].id, \[tbl1\].code,\[tbl1\].mflag, \[tbl2\].cdnum, \[tbl3\].bname"
            ssql = ssql & " FROM  \[tbl1\] INNER JOIN"
            ssql = ssql & " \[tbl2\] ON"
            ssql = ssql & " \[tbl1\].id = \[tbl2\].id INNER JOIN"
            ssql = ssql & " \[tbl3\] ON \[tbl1\].code = \[tbl3\].code"
            ssql = ssql & " WHERE \[tbl1\].mdate ='2011/10/12'"      
        Else 'DB2
            ADODisconn 'disconnect to DB1
         
            ADOConDB2  'connect to DB2        
            
             ssql = "SELECT \[tbl2\].id,\[tbl2\].code,\[tbl2\].mflag,\[tbl2\].cdnum,\[tbl3\].bname"
             ssql = ssql & " FROM  \[tbl2\] INNER JOIN \[tbl3\] ON "
             ssql = ssql & " \[tbl2\].code = \[tbl3\].code"
             ssql = ssql & " WHERE \[tbl2\].id > 160" 
        End If
        

        Me.RecordSource = ssql
        Me.UniqueTable = "tbl2"

        End Sub

        C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

        A L 2 Replies Last reply
        0
        • C C Coudou

          thanks. i check the db2 and it has the same table. is my approach correct? i mean connecting other database in an access form. here is my snippet code: ACCESS FORM

          'Default database DB1
          Private Sub Form_Open(Cancel As Integer)
          Dim ssql As String

          ssql = "SELECT \[tbl1\].id, \[tbl1\].code,\[tbl1\].mflag, \[tbl2\].cdnum, \[tbl3\].bname"
          ssql = ssql & " FROM  \[tbl1\] INNER JOIN"
          ssql = ssql & " \[tbl2\] ON"
          ssql = ssql & " \[tbl1\].id = \[tbl2\].id INNER JOIN"
          ssql = ssql & " \[tbl3\] ON \[tbl1\].code = \[tbl3\].code"
          ssql = ssql & " WHERE \[tbl1\].mdate ='2011/10/12'"
          Me.RecordSource = ssql
          
          Me.UniqueTable = "tbl2"
          

          End Sub

          'option to select DB1 or DB2
          Private Sub optSel_AfterUpdate()
          Dim ssql As String

          'DB1
          If Me.optSel = 1 Then
              ssql = "SELECT \[tbl1\].id, \[tbl1\].code,\[tbl1\].mflag, \[tbl2\].cdnum, \[tbl3\].bname"
              ssql = ssql & " FROM  \[tbl1\] INNER JOIN"
              ssql = ssql & " \[tbl2\] ON"
              ssql = ssql & " \[tbl1\].id = \[tbl2\].id INNER JOIN"
              ssql = ssql & " \[tbl3\] ON \[tbl1\].code = \[tbl3\].code"
              ssql = ssql & " WHERE \[tbl1\].mdate ='2011/10/12'"      
          Else 'DB2
              ADODisconn 'disconnect to DB1
           
              ADOConDB2  'connect to DB2        
              
               ssql = "SELECT \[tbl2\].id,\[tbl2\].code,\[tbl2\].mflag,\[tbl2\].cdnum,\[tbl3\].bname"
               ssql = ssql & " FROM  \[tbl2\] INNER JOIN \[tbl3\] ON "
               ssql = ssql & " \[tbl2\].code = \[tbl3\].code"
               ssql = ssql & " WHERE \[tbl2\].id > 160" 
          End If
          

          Me.RecordSource = ssql
          Me.UniqueTable = "tbl2"

          End Sub

          C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

          A Offline
          A Offline
          Abhinav S
          wrote on last edited by
          #4

          There is no UPDATE query in this code so its really difficult to figure out.

          C 1 Reply Last reply
          0
          • A Abhinav S

            There is no UPDATE query in this code so its really difficult to figure out.

            C Offline
            C Offline
            C Coudou
            wrote on last edited by
            #5

            no. the update is on the form. Using the Continuous Forms The same as GridiView in visual basic. In detail of continuous form, I have textboxes and checkboxes, if I check the checkbox, the table is automatically updated. Database update is not on the code, its on the form.

            C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

            1 Reply Last reply
            0
            • C C Coudou

              thanks. i check the db2 and it has the same table. is my approach correct? i mean connecting other database in an access form. here is my snippet code: ACCESS FORM

              'Default database DB1
              Private Sub Form_Open(Cancel As Integer)
              Dim ssql As String

              ssql = "SELECT \[tbl1\].id, \[tbl1\].code,\[tbl1\].mflag, \[tbl2\].cdnum, \[tbl3\].bname"
              ssql = ssql & " FROM  \[tbl1\] INNER JOIN"
              ssql = ssql & " \[tbl2\] ON"
              ssql = ssql & " \[tbl1\].id = \[tbl2\].id INNER JOIN"
              ssql = ssql & " \[tbl3\] ON \[tbl1\].code = \[tbl3\].code"
              ssql = ssql & " WHERE \[tbl1\].mdate ='2011/10/12'"
              Me.RecordSource = ssql
              
              Me.UniqueTable = "tbl2"
              

              End Sub

              'option to select DB1 or DB2
              Private Sub optSel_AfterUpdate()
              Dim ssql As String

              'DB1
              If Me.optSel = 1 Then
                  ssql = "SELECT \[tbl1\].id, \[tbl1\].code,\[tbl1\].mflag, \[tbl2\].cdnum, \[tbl3\].bname"
                  ssql = ssql & " FROM  \[tbl1\] INNER JOIN"
                  ssql = ssql & " \[tbl2\] ON"
                  ssql = ssql & " \[tbl1\].id = \[tbl2\].id INNER JOIN"
                  ssql = ssql & " \[tbl3\] ON \[tbl1\].code = \[tbl3\].code"
                  ssql = ssql & " WHERE \[tbl1\].mdate ='2011/10/12'"      
              Else 'DB2
                  ADODisconn 'disconnect to DB1
               
                  ADOConDB2  'connect to DB2        
                  
                   ssql = "SELECT \[tbl2\].id,\[tbl2\].code,\[tbl2\].mflag,\[tbl2\].cdnum,\[tbl3\].bname"
                   ssql = ssql & " FROM  \[tbl2\] INNER JOIN \[tbl3\] ON "
                   ssql = ssql & " \[tbl2\].code = \[tbl3\].code"
                   ssql = ssql & " WHERE \[tbl2\].id > 160" 
              End If
              

              Me.RecordSource = ssql
              Me.UniqueTable = "tbl2"

              End Sub

              C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              C#Coudou wrote:

              is my approach correct?
              i mean connecting other database in an access form.
               
              here is my snippet code: ACCESS FORM

              It looks like VB.NET, but I don't see any OleDbCommand's. Are you using the "old" recordsets? FWIW; I don't see any code where you bind the data to the UI, nor where you re-open the new connection. The best suggestion I can give is to use the OleDb provider to access your database.

              Bastard Programmer from Hell :suss:

              C 1 Reply Last reply
              0
              • L Lost User

                C#Coudou wrote:

                is my approach correct?
                i mean connecting other database in an access form.
                 
                here is my snippet code: ACCESS FORM

                It looks like VB.NET, but I don't see any OleDbCommand's. Are you using the "old" recordsets? FWIW; I don't see any code where you bind the data to the UI, nor where you re-open the new connection. The best suggestion I can give is to use the OleDb provider to access your database.

                Bastard Programmer from Hell :suss:

                C Offline
                C Offline
                C Coudou
                wrote on last edited by
                #7

                nope, this is not vb.net, this is MS Access, that is why you cannot see an oledbcommand.yes, I'm using old recordsets. You can't see open connection because in the Form1 properties, it has recordsource, also in form open. If i will use oledb connection, how can i add the data's in my continuous form? This project is an .adp(microsoft access project),which means if you open the myproject.adp, it is already connected to database.

                C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

                L 1 Reply Last reply
                0
                • C C Coudou

                  nope, this is not vb.net, this is MS Access, that is why you cannot see an oledbcommand.yes, I'm using old recordsets. You can't see open connection because in the Form1 properties, it has recordsource, also in form open. If i will use oledb connection, how can i add the data's in my continuous form? This project is an .adp(microsoft access project),which means if you open the myproject.adp, it is already connected to database.

                  C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  C#Coudou wrote:

                  nope, this is not vb.net, this is MS Access, that is why you cannot see an oledbcommand.yes, I'm using old recordsets.

                  My apologies, I assumed VB.NET - that's the name of the forum.

                  C#Coudou wrote:

                  If i will use oledb connection, how can i add the data's in my continuous form?

                  I don't think that will work; those reports are built for use within Access itself.

                  C#Coudou wrote:

                  This project is an .adp(microsoft access project),which means if you open the myproject.adp, it is already connected to database.

                  Not even sure whether Access allows switching the current connection. It's been some time ago that I worked in Access, and we didn't "switch" the connection to another database - we decided it was easier to import the data from other databases, and manipulate it in the current connection.

                  Bastard Programmer from Hell :suss:

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups