Wrox Programmer Forums
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
Old November 25th, 2005, 06:30 AM
Authorized User
Join Date: Nov 2005
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default display data in the dropdown

 How do i populate dropdown box on basis of the query written in vb.
i am using access forms.

here is the code
thanks in advance.

Dim abc As String
Dim db As ADODB.connection
Set db = New ADODB.connection
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
'Make Connection with the Database.
connstr = "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=CVTracker;Initial Catalog=CVTracker"
db.Open (connstr)
Sql = "Select * From ContactDetails where UserID =" & Form_frmMain.ID
Set rs = db.Execute(Sql)

While Not rs.EOF

-------Some Code Requried here s the code i am missing something in while loop.
how to achieve this.


Best Regards,
Best Regards,
Old November 25th, 2005, 07:02 PM
Authorized User
Join Date: Sep 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Matthew

Follow this step
Place the dropdown control and draw, make sure that Wizard is not on
1. Right click the comb and rename it tp cboselect.
2. On the row source click on the ... and choose the table you want to retrieve information from.
3. Select the table ID and the name of the field you want.
4. close and choose save when asked to save and continue
5. On the bound column 1
6. Column width 0cm; 4cm
7. Right click on the drop down and click on event
8. Click on After Update and select Event procedure and click ...
past this code seen below

Private Sub cboselect_AfterUpdate()
Dim Title As String
Title = " Sango Plaza Hotel Limited "
On Error GoTo ErrorHandler
Dim StrSearch As String

StrSearch = "[NameID]=" & Me![cboselect]
Me.RecordsetClone.FindFirst StrSearch
Me.Bookmark = Me.RecordsetClone.Bookmark

Exit Sub
MsgBox Err.Description
Resume ErrorHandlerExit

Click on the top of the on design mode and select On Current.

Enter this code
On Error GoTo ErrorHandler
Me![cboselect] = Null

Exit Sub
MsgBox "Error No: " & Err.Number & "; Description:" & Err.Description
Resume ErrorHandlerExit

You are done
God luck!

Matthew Ikechukwu
Email: admin@makaiit.net

Similar Threads
Thread Thread Starter Forum Replies Last Post
dropdown display itemlist when onmouseover it anupamapapillu Javascript 0 February 28th, 2008 06:35 AM
Selected value from dropdown menu wont display. mizjinx Classic ASP Databases 0 May 20th, 2007 08:24 PM
Data from Dropdown List to TextBox caterpillar General .NET 1 July 10th, 2006 06:05 AM
DropDown display issues msrnivas General .NET 0 August 23rd, 2005 07:48 PM
How to bind data to a dropdown in a datalist thats broushly ASP.NET 1.0 and 1.1 Basics 1 April 28th, 2004 01:52 PM

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