sending from form back to a table and than printing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chembuff1982
    New Member
    • Mar 2007
    • 27

    sending from form back to a table and than printing

    I have part of my form done, called frmcustomers with drop down menus which are working fine, thanks to prior help on here. Now I have an issue, I want to be able to send my information selected in my checkboxes back to a new table with everything checked, I don't want it to go back in the table I already use to get the information from the check boxes. I have a cmd print button, and I want to use that to first, use the information selected send back to my new table and than print that set of information out, I have a couple of fields that will go in the table, client, test, time, date. If anyone can help, much appreciation.

    Justin
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Hi Justin

    Sorry I'm not sure what you are trying to do. Do you want to add a record to another table based on the current selections in the form?

    Mary

    Comment

    • chembuff1982
      New Member
      • Mar 2007
      • 27

      #3
      Yes, from my checkbox selections which are already displayed on the form through a table and selectable I want to hit the print button which I have printing fine already, but before it prints, I want someway to send the selections on the drop down to a new table called login. I have time and date set up, customer name set up and customer test. Any help would be appreciated thanks for the response Mary. I have the empty table, I just need to know how to take my information from the checkboxes and date, and send them to each field in this table, for Customer, test, date, etc. One simple example would be fine, I've tried to search all over the net, and my access book is useless. I use to program years ago, I'm so rusty now it's not even funny. I do mostly lab work and secretarial. I'll send a donation in when I complete the project, because this site is so helpful to me and I'm thankful for that.

      Comment

      • chembuff1982
        New Member
        • Mar 2007
        • 27

        #4
        Can anyone help?

        Comment

        • MMcCarthy
          Recognized Expert MVP
          • Aug 2006
          • 14387

          #5
          Originally posted by chembuff1982
          Can anyone help?
          Would something like this work?
          Code:
          Dim strSQL As String
          
             strSQL = "INSERT INTO Login (Customer, test, date) " & _
          	   "VALUES('" & Me!Customer & "', '" &  Me!test & "', #" & _
          	   Me!date & "#)"
             DoCmd.RunSQL strSQL
          This assumes Customer and test are text fields and have the same textbox names on the form as column names in the table.

          Mary

          Comment

          • chembuff1982
            New Member
            • Mar 2007
            • 27

            #6
            Here's my code
            Code:
            Private Sub cmdprint_Click()
            On Error GoTo Err_cmdprint_Click
            Dim stDocName As String
                Dim MyForm As Form
            
                stDocName = "tbldate"
                Set MyForm = Screen.ActiveForm
                DoCmd.SelectObject acTable, stDocName, True
                DoCmd.PrintOut
                DoCmd.SelectObject acForm, MyForm.Name, False
                Text54.Value = Now()
                Text54.Visible = True
                
                Exit_cmdprint_Click:
                Exit Sub
            
            Err_cmdprint_Click:
                MsgBox Err.Description
                Resume Exit_cmdprint_Click
            End Sub
            
            Private Sub Combo27_AfterUpdate()
            Dim rs As Object
            Set rs = Me.Recordset.Clone
                rs.FindFirst "[CompanyID] = " & Str(Nz(Me![Combo27], 0))
                If Not rs.EOF Then Me.Bookmark = rs.Bookmark
                Me.Combo29.Requery
               Combo29.Visible = True
            
            End Sub
            
            Private Sub Combo27_Change()
              cmdprint.Visible = False
              
            Dim strCustomer As String ' define string
            
                    strCustomer = strCustomer & "" & Me.Combo27.SelText & ", "
            'appending the value to string from box
              
                ' remove excess off string in append
                strCustomer = Left(strCustomer, Len(strCustomer) - 2)
            
            MsgBox strCustomer
            End Sub
            
            Private Sub Combo29_AfterUpdate()
             cmdprint.Visible = True
             
            End Sub
            
            Private Sub Combo29_Change()
            Dim strTest As String ' define string Test to use for append
            
                    strTest = strTest & "" & Me.Combo29.SelText & ", " 'append string from combobox
            
            ' to remove excess comma stored in append
                strTest = Left(strTest, Len(strTest) - 2)
                cmdprint.Visible = True
            End Sub
            
            Private Sub Form_Load()
              Text54.Visible = False
              Combo29.Visible = False
              cmdprint.Visible = False
                
            End Sub

            I want those strings from Combo27 (to go into TablePrint in field CustomerPrint), and Combo29( to go into TablePrint in field TestPrint).

            Comment

            • MMcCarthy
              Recognized Expert MVP
              • Aug 2006
              • 14387

              #7
              Originally posted by chembuff1982

              I want those strings from Combo27 (to go into TablePrint in field CustomerPrint), and Combo29( to go into TablePrint in field TestPrint).
              Are these new records to be appended or are you trying to update existing records?

              Comment

              • chembuff1982
                New Member
                • Mar 2007
                • 27

                #8
                Originally posted by mmccarthy
                Are these new records to be appended or are you trying to update existing records?

                They are new records I'm storing them, taking them originally from a table, and upon selection, through the drop down boxes, sending the submitted results to a new table to store the selections. Just pretty much for record keeping of clients and tests that go on.

                Comment

                • MMcCarthy
                  Recognized Expert MVP
                  • Aug 2006
                  • 14387

                  #9
                  Originally posted by chembuff1982
                  They are new records I'm storing them, taking them originally from a table, and upon selection, through the drop down boxes, sending the submitted results to a new table to store the selections. Just pretty much for record keeping of clients and tests that go on.
                  The problem is that the two values are being retrieved in two separate procedures. You need to consider the following.

                  Storing the values in public variables for use later.

                  Creating a Add to table button which will retrieve the values from the two combo boxes and insert them into the table.
                  Code:
                  Dim strSQL As String
                  
                     strSQL = "INSERT INTO TablePrint (CustomerPrint, TestPrint) " & _
                  	   "VALUES('" & Me!Combo27 & "', '" & Me!Combo29 & "')"
                     DoCmd.RunSQL strSQL
                  Mary

                  Comment

                  Working...