Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 3rd, 2004, 10:49 PM
Authorized User
Join Date: Nov 2004
Location: Caloocan, Philippines, Philippines.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Combo Box

I'm a new coder. Please help me. I want to use the field(PRDNAME) to be browse by the user using combo box. How to connect it.

dbMain.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Persist Security Info=False;" & _
                "Data Source=D:\Visual\Slpi.mdb"


rsCategory.Open SQLCategory, dbMain, adOpenDynamic, adLockOptimistic ' Opening the Category Recordset

For x = 1 To rsCategory.RecordCount

    Combo1.AddItem rsCategory.Fields("CATEGORYNAME")
Next x

  #2 (permalink)  
Old November 4th, 2004, 08:58 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts


   Maybe I am not understanding what you want, but it sounds like you want to use a combo box so the user can browse records on a form. If that is the case, then just use the Combo Box wizard. At the first prompt, check the radio button that says you want to find a record on your form using the combo box.

   Then on the Form's On Click event, put this code to synchronize the combo box with the records:

   cboComboBoxName = RecordPrimaryKeyName

   This will allow the user to use the combo box to find a record. The code attached to the combo box After Update event looks like this:

 ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[PK] = " & Str(Nz(Me![ComboName], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark

   IMPORTANT: The combo box Row Source is a query that looks up the value(s) you want the user to browse by. The bound column is usually the Primary Key.

I hope this helps.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate a text box from a combo box value dnf999 Access VBA 7 February 6th, 2012 02:24 PM
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.