473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

put a record in a drop down box

Here's my code, combo27 is working fine, however when I update my table Test (field Test) which works fine, I can't get Combo29 to update to the added test I just put in. I need to use the acLast or something like it to bring my record up, which works, however, it's numeric. I need to know how to bring the string value in the cell back to my drop down Combo29 here's my full code and form for the whole database, take a looksee if you want.

[IMG]C:\Documents and Settings\Justin\Desktop\form.jpg[/IMG]

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. ####################
  23.  
  24. Private Sub Combo27_AfterUpdate()
  25. Dim rs As Object
  26. Set rs = Me.Recordset.Clone
  27.     rs.FindFirst "[CompanyID] = " & Str(Nz(Me![Combo27], 0))
  28.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  29.  
  30.     Me.Combo29.Requery
  31.  
  32.    Combo29.Visible = True
  33.  
  34. End Sub
  35.  
  36. ######################
  37.  
  38. Private Sub Combo27_Change()
  39.   cmdprint.Visible = False
  40.   Dim strCustomer As String
  41.  
  42. ' define string
  43.  
  44.         strCustomer = strCustomer & "" & Me.Combo27.SelText & ", "
  45.  
  46. 'appending the value to string from box
  47.  
  48.     ' remove excess off string in append
  49.     strCustomer = Left(strCustomer, Len(strCustomer) - 2)
  50.    pass (strCustomer)
  51.  
  52. End Sub
  53.  
  54. #############
  55.  
  56. Private Sub Combo29_AfterUpdate()
  57.  
  58.  cmdprint.Visible = True
  59.  
  60. End Sub
  61.  
  62. #######################
  63.  
  64. Private Sub Combo29_Change()
  65. Dim strTest As String ' define string Test to use for append
  66.  
  67.         strTest = strTest & "" & Me.Combo29.SelText & ", " 'append string from combobox
  68.  
  69.     ' to remove excess comma stored in append
  70.     strTest = Left(strTest, Len(strTest) - 2)
  71.     pass2 (strTest)
  72.  
  73.     cmdprint.Visible = True
  74.     DoCmd.GoToRecord acDataForm, "Test", acLast
  75.  
  76. End Sub
  77.  
  78. ########################
  79.  
  80. Private Sub Form_Load()
  81.   Text54.Visible = False
  82.   Combo29.Visible = False
  83.   cmdprint.Visible = False
  84.  
  85. End Sub
  86.  
  87. #######################
  88.  
  89. Sub pass(x As String)
  90.  
  91.    Dim store As String
  92.  
  93.   store = x
  94.   If cmdprint.Visible = True Then
  95.  
  96.    Dim strSQL As String
  97.  
  98.    strSQL = "INSERT INTO TablePrint (CustomerPrint) " & _
  99.        "VALUES('" & store & "')"
  100.    DoCmd.RunSQL strSQL
  101.  
  102.     DoCmd.GoToRecord , , acNewRec
  103.    End If
  104.  
  105. End Sub
  106.  
  107. ####################
  108.  
  109. Sub pass2(y As String)
  110.   Dim store2 As String
  111.   store2 = y
  112.     If cmdprint.Visible = True Then
  113.  
  114.     Dim strSQL As String
  115.  
  116.    strSQL = "INSERT INTO TablePrint (CustomerTest) " & _
  117.        "VALUES('" & store2 & "')"
  118.    DoCmd.RunSQL strSQL
  119.  
  120.     DoCmd.GoToRecord , , acNewRec
  121.  
  122.    End If
  123. End Sub
  124.  
  125. #################
  126.  
  127. Private Sub Add_Test_Click()
  128. On Error GoTo Err_Add_Test_Click
  129.   Dim clienttest As String
  130.    Combo29.Visible = True
  131.   clienttest = InputBox("Enter Test Data Please, seperate with commas")
  132.  
  133.      updatecombo29 (clienttest)
  134.  
  135. Exit_Add_Test_Click:
  136.     Exit Sub
  137.  
  138. Err_Add_Test_Click:
  139.     MsgBox Err.Description
  140.     Resume Exit_Add_Test_Click
  141.  
  142. End Sub
  143.  
  144. #######################
  145.  
  146. Private Sub Add_Client_Click()
  147. On Error GoTo Err_Add_Client_Click
  148.   Dim clientname As String
  149.   clientname = InputBox("Enter Client Name")
  150.   Combo27.Value = clientname
  151.  
  152.     DoCmd.GoToRecord , , acNewRec
  153.  
  154. Exit_Add_Client_Click:
  155.     Exit Sub
  156.  
  157. Err_Add_Client_Click:
  158.     MsgBox Err.Description
  159.     Resume Exit_Add_Client_Click
  160.  
  161. End Sub
  162.  
  163. ###################
  164.  
  165. Sub updatecombo29(update As String)
  166.   Dim change As String
  167.   Dim lastrecord As String
  168.  
  169.   change = update
  170.  
  171.     Dim strSQL As String
  172.  
  173.    strSQL = "INSERT INTO Test (Test) " & _
  174.        "VALUES('" & change & "')"
  175.    DoCmd.RunSQL strSQL
  176.     DoCmd.GoToRecord , , acNewRec
  177.  
  178. End Sub
  179.  
Mar 30 '07 #1
12 1734
http://i147.photobucket.com/albums/r301/chembuff1982/form.jpg

that's a picture of my form I took a snapshot of, not an advertisement. It's in my photobucket.
Mar 30 '07 #2
anyone? Almost there, almost there, so close to being done.
Apr 1 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Try this ...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo29_Change()
  2. Dim strTest As String ' define string Test to use for append
  3.  
  4.                strTest = strTest & "" & Me.Combo29.SelText & ", " 
  5.       'append string from combobox
  6.  
  7.       ' to remove excess comma stored in append
  8.    strTest = Left(strTest, Len(strTest) - 2)
  9.       pass2 (strTest)
  10.  
  11.    cmdprint.Visible = True
  12.  
  13.    Me.Combo29.Requery
  14.  
  15. End Sub
Apr 1 '07 #4
That doesn't work, I did try that a while ago, see the table, is updated by the form, but I'm trying to sort of refresh the new drop down box with the new selection. Would some form of acLast work? I got aclast to pull up a number for the new record, but I need a string value.
Apr 2 '07 #5
So frustrating, it's the last button on the form. I have it sending to the table, just need ot repopulate my combo29 box which is for client tests. I want it to do it from the add test button. So if a current client has no selection or they are a new client it will allow them to enter test parameters.
Apr 2 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
So frustrating, it's the last button on the form. I have it sending to the table, just need ot repopulate my combo29 box which is for client tests. I want it to do it from the add test button. So if a current client has no selection or they are a new client it will allow them to enter test parameters.
Sorry I'm genuinely lost as to what you're trying to do :)
Apr 2 '07 #7
my rowsource for combo29 (tests) is filtered by companyID number, however if we add a new test for a company, or add a new company, I want to be able to put that new test from add test in the Combo29 (tests) box before the form is submitted.
Apr 2 '07 #8
MMcCarthy
14,534 Expert Mod 8TB
my rowsource for combo29 (tests) is filtered by companyID number, however if we add a new test for a company, or add a new company, I want to be able to put that new test from add test in the Combo29 (tests) box before the form is submitted.
So your problem then is when to trigger the requery.

How are new tests being added?
Apr 2 '07 #9
The new tests are being added by a command button.
Add New Test
Apr 2 '07 #10
MMcCarthy
14,534 Expert Mod 8TB
The new tests are being added by a command button.
Add New Test
Put the requery here
Expand|Select|Wrap|Line Numbers
  1. Private Sub Add_Test_Click()
  2. On Error GoTo Err_Add_Test_Click
  3. Dim clienttest As String
  4.    Combo29.Visible = True
  5.    clienttest = InputBox("Enter Test Data Please, seperate with commas")
  6.  
  7.    updatecombo29 (clienttest)
  8.    Me!Combo29.Requery
  9.  
And maybe put it in the Load event of the form.

Mary
Apr 2 '07 #11
Nope both changes didn't work. I think we came upon a mystery of computer programming.
Apr 3 '07 #12
I'm going to try to go to the local college to get help. It seems like nobody on here can figure the last part out. I called already, just going to talk to a professor who has a degree in computer science.
Apr 4 '07 #13

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

Similar topics

6
by: Rey | last post by:
Howdy, all. Appreciate your help. Have a one to many relation between a client and visit table. In the visit subform, I have a visittype and counselor field which are comboboxes. If I set...
0
by: Alienz | last post by:
hiya! I wanted to make a multiple selection drop down list and I found the easiest way to do this was by creating a subform linked to a table with 2 values, the 1st value links to the main form...
4
by: thebison | last post by:
Hi all, I hope someone can help with this relatively simple problem. I am building a timesheet application using ASP.NET C# with Visual Studio 2003.As it is only a protoype application, my...
1
by: Per | last post by:
Hi, I have a problem that I can't figure out. I have a database application to keep track of boxes that contain files. For data entry, I have a form with a main form section for the box-specific...
0
by: uthooker | last post by:
I have an Access form with some combo boxes in the Form Header that are enabled/disabled using conditional formatting based on the setting in a checkbox also in the Header (Combo box = Enabled by...
1
lwwhite
by: lwwhite | last post by:
Another question. On one of my forms, I have two radio buttons: Topic and Window. Beside each of them is a drop-down to select the corresponding topic or window. When Topic is selected the window...
10
by: sara | last post by:
Hi - I have been struggling with solution ideas for this now for almost 2 weeks, and have not been able to figure this out. I have a user who creates a Purchase Order (tblPOData). In some...
5
by: kcddoorman | last post by:
I have a main order table that gets some of its information from several look up tables. A create a look up relationship between the two tables and that allows me to choose a record. I can create...
0
by: daverskully | last post by:
I have two tables created and want to link two forms created from these tables so that specific fields are populated once one field is selected, but not all fields being populated, with a new record...
2
by: daverskully | last post by:
I have two tables created and want to link two forms created from these tables so that specific fields are populated once one field is selected, but not all fields being populated, with a new record...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.