Copy one row after checkbox is checked from one table to another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Blazej
    New Member
    • Sep 2006
    • 2

    Copy one row after checkbox is checked from one table to another

    First of all I want to say Hi to every one. So.. Hi :)

    I'm new in Access, so please be patient. I've got this problem:
    I have a subform, where user can see results from one table called A. There is a checkbox in one of the columns in this table.
    What I want to do is to copy the specific row, after user will check the checkbox, as a new row to another table called B. But I don't want to make exact copy, but only values from three columns from A into three columns (with different names) in column B.

    Thanks for help.
  • jmclueless
    New Member
    • Sep 2006
    • 3

    #2
    I'm trying to do the same thing. I have writer's block.

    Comment

    • kiask2343
      New Member
      • Sep 2006
      • 10

      #3
      I am looking for something very simular, have one person helping me, but I am the newest of newbs to VBA and access. If it is ok I would like to monitor this thread as well as mine.

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        Open the subform in design view.

        Go to the checkbox control. Right click on it and go to the events tab.

        Go down to the After Update Event and click the little black arrow and select [Event Procedure] then click on the little button with dots beside it.

        The VB Editior will open with the following:

        Private Sub CheckBoxName_Af terUpdate()

        End Sub

        In between these two lines put the following:

        Code:
         
        Private Sub CheckBoxName_AfterUpdate()
        Dim strSQL As String
         
          strSQL = "INSERT INTO TableB (FieldB1, FieldB2, FieldB3) " & _
        				"SELECT " & Me.Field1 & " As Expr1, " & Me.Field2 & _
        				" As Expr2, " & Me.Field3 & " As Expr3;"
         
          CurrentDb.Execute strSQL, dbFailOnError
         
        End Sub

        Comment

        • Blazej
          New Member
          • Sep 2006
          • 2

          #5
          Thank You. This is exactly what I need.

          Originally posted by mmccarthy
          Open the subform in design view.

          Go to the checkbox control. Right click on it and go to the events tab.

          Go down to the After Update Event and click the little black arrow and select [Event Procedure] then click on the little button with dots beside it.

          The VB Editior will open with the following:

          Private Sub CheckBoxName_Af terUpdate()

          End Sub

          In between these two lines put the following:

          Code:
           
          Private Sub CheckBoxName_AfterUpdate()
          Dim strSQL As String
           
            strSQL = "INSERT INTO TableB (FieldB1, FieldB2, FieldB3) " & _
          				"SELECT " & Me.Field1 & " As Expr1, " & Me.Field2 & _
          				" As Expr2, " & Me.Field3 & " As Expr3;"
           
            CurrentDb.Execute strSQL, dbFailOnError
           
          End Sub

          Comment

          • jmclueless
            New Member
            • Sep 2006
            • 3

            #6
            Here's what I need to do:

            User enters data on formA and subformA. One field on subformA is a check box. If checkbox is checked need to copy some fields for each of those records to FormB, SubformB, when user clicks button. Both forms use the same tables.

            I'm am sure these are several ways to accomplish this; but still having writer's block.

            Any help would be appreciated.

            Thanks,

            Janice

            Comment

            Working...