By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

sending from form back to a table and than printing

P: 27
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
Mar 16 '07 #1
Share this Question
Share on Google+
8 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
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
Mar 17 '07 #2

P: 27
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.
Mar 19 '07 #3

P: 27
Can anyone help?
Mar 20 '07 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
Can anyone help?
Would something like this work?
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3.    strSQL = "INSERT INTO Login (Customer, test, date) " & _
  4.        "VALUES('" & Me!Customer & "', '" &  Me!test & "', #" & _
  5.        Me!date & "#)"
  6.    DoCmd.RunSQL strSQL
  7.  
This assumes Customer and test are text fields and have the same textbox names on the form as column names in the table.

Mary
Mar 22 '07 #5

P: 27
Here's my code
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdprint_Click()
  2. On Error GoTo Err_cmdprint_Click
  3. Dim stDocName As String
  4.     Dim MyForm As Form
  5.  
  6.     stDocName = "tbldate"
  7.     Set MyForm = Screen.ActiveForm
  8.     DoCmd.SelectObject acTable, stDocName, True
  9.     DoCmd.PrintOut
  10.     DoCmd.SelectObject acForm, MyForm.Name, False
  11.     Text54.Value = Now()
  12.     Text54.Visible = True
  13.  
  14.     Exit_cmdprint_Click:
  15.     Exit Sub
  16.  
  17. Err_cmdprint_Click:
  18.     MsgBox Err.Description
  19.     Resume Exit_cmdprint_Click
  20. End Sub
  21.  
  22. Private Sub Combo27_AfterUpdate()
  23. Dim rs As Object
  24. Set rs = Me.Recordset.Clone
  25.     rs.FindFirst "[CompanyID] = " & Str(Nz(Me![Combo27], 0))
  26.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  27.     Me.Combo29.Requery
  28.    Combo29.Visible = True
  29.  
  30. End Sub
  31.  
  32. Private Sub Combo27_Change()
  33.   cmdprint.Visible = False
  34.  
  35. Dim strCustomer As String ' define string
  36.  
  37.         strCustomer = strCustomer & "" & Me.Combo27.SelText & ", "
  38. 'appending the value to string from box
  39.  
  40.     ' remove excess off string in append
  41.     strCustomer = Left(strCustomer, Len(strCustomer) - 2)
  42.  
  43. MsgBox strCustomer
  44. End Sub
  45.  
  46. Private Sub Combo29_AfterUpdate()
  47.  cmdprint.Visible = True
  48.  
  49. End Sub
  50.  
  51. Private Sub Combo29_Change()
  52. Dim strTest As String ' define string Test to use for append
  53.  
  54.         strTest = strTest & "" & Me.Combo29.SelText & ", " 'append string from combobox
  55.  
  56. ' to remove excess comma stored in append
  57.     strTest = Left(strTest, Len(strTest) - 2)
  58.     cmdprint.Visible = True
  59. End Sub
  60.  
  61. Private Sub Form_Load()
  62.   Text54.Visible = False
  63.   Combo29.Visible = False
  64.   cmdprint.Visible = False
  65.  
  66. End Sub
  67.  

I want those strings from Combo27 (to go into TablePrint in field CustomerPrint), and Combo29( to go into TablePrint in field TestPrint).
Mar 22 '07 #6

MMcCarthy
Expert Mod 10K+
P: 14,534

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?
Mar 25 '07 #7

P: 27
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.
Mar 26 '07 #8

MMcCarthy
Expert Mod 10K+
P: 14,534
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.
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3.    strSQL = "INSERT INTO TablePrint (CustomerPrint, TestPrint) " & _
  4.        "VALUES('" & Me!Combo27 & "', '" & Me!Combo29 & "')"
  5.    DoCmd.RunSQL strSQL
  6.  
Mary
Mar 26 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.