Results 1 to 6 of 6
  1. #1
    chleng is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    11

    How to pass value from textbox to combobox?

    Hi all.

    I am new to access.

    Does anyone know how to pass value from TextBox to ComboBox in VBA?

    Controls in my form:
    ItemCode textbox - user to key in the itemcode
    SpeID1 textbox - LEFT(itemcode,2)
    SpeID combobox - pass value from SpeID1 textbox to SpeID combobox
    Desc textbox - Dlookup Desc from Species table using SpeID

    The Desc will come out if I run the following code by choosing the value from the dropdown combobox without using the SpeID1 textbox
    Code:

    Private Sub SpeID_AfterUpdate()Desc = DLookup("Desc", "Species", "SpeID='" & SpeID & "'")End Sub

    but what I want here is the user need not to choose the value from the SpeID Combobox and the SpeID and Desc will come out automatically after the user enter itemcode.



    I try to use SpeID1_AfterUpdate() but no value appears at the Desc.

    Anyone here kindly share your advice with me.

    Thanks.

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Welcome to the forum!

    How is the combo box currently getting its data: table/query or value list?

  3. #3
    chleng is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    11
    Quote Originally Posted by jzwp11 View Post
    Welcome to the forum!

    How is the combo box currently getting its data: table/query or value list?
    Hi, jzwp11.

    The combo box is getting its data from table.

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    To get the value from the text box to the combo box, you have to add the value to the underlying table via an append query (or recordset) and then requery the combo box.

  5. #5
    chleng is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    11
    Quote Originally Posted by jzwp11 View Post
    To get the value from the text box to the combo box, you have to add the value to the underlying table via an append query (or recordset) and then requery the combo box.
    Do you mind to share with me the step by step? I am novice to MS Access

  6. #6
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You'll have to provide a little more background as to what you are doing. It sounds like you have users who are selecting items from a combo box but on occassion they may have an item that is not in the combo box (and hence not in the underlying table). Instead of using a text box in conjunction with the combo box, you could just use the combo box and utilize its not in list event to open up a form where the user can enter the new item. The user would actually type the item in the combo box. Roger Carlson has an example database that does just that on his site. After you download the database, you would want to select Option 5 from the switchboard that opens when you open the database.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. SET focus back to TEXTBOX if validation does NOT pass
    By taimysho0 in forum Programming
    Replies: 5
    Last Post: 12-04-2011, 10:10 PM
  2. On click textbox inserts value back on combobox
    By whitelockben in forum Forms
    Replies: 2
    Last Post: 10-09-2011, 05:23 AM
  3. Display PASS or FAIL using Unbound textbox
    By Shambler2 in forum Reports
    Replies: 7
    Last Post: 06-02-2011, 11:19 AM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums