Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / March 2006

Tip: Looking for answers? Try searching our database.

combo box problems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Claire Rohan - 14 Mar 2006 16:54 GMT
hi there,
I have a combo box in the form header of my main form which I wish to use to
select a record. I use the combo box wizard to create it and selected the
"find a record based on..." option. the problem is that when the user clicks
on the down arrow of the combo box, while it opens to show the values, the
user cannot select a value so the correct record is not then shown..
I would also like to know how to use a filter so that only the records in
which a certain field (called closedate) is null, are available for the user
to scroll through??
many thanks,
claire rohan
Ken Sheridan - 14 Mar 2006 19:35 GMT
Claire:

Lets take a simple example.  Say you have a table Contracts with columns
amongst others of contacted (a numeric primary key), contracttitle (text) and
your closedate column (date/time).  To get the form to show only those rows
where the closedate column is Null you'd base the form on a query:

SELECT *
FROM Contracts
WHERE closedate IS NULL
ORDER BY contracttitle;

The combo box in the form's header to enable you to select a record by
contacttitle from all non-Null closedate contacts would have a RowSource
property of:

SELECT contractID, contracttitle
FROM Contracts
WHERE closedate IS NULL
ORDER BY contracttitle;

The properties of this combo box would be:

ControlSource:    leave blank
BoundColumn:    1
ColumnCount      2
ColumnWidths    0cm;8cm    or rough equivalent in inches

The first dimension of the last property must be zero to hide the first
column, the second dimension isn't crucial so long as its at least as wide as
the control.

In the AfterUpdate event procedure of the combo box put the following code:

   Dim rst As Object
   
   Set rst = Me.Recordset.Clone
   
   rst.FindFirst "contractID = " & cboFindContract
   Me.Bookmark = rst.Bookmark

where cboFindContract is the name of the combo box.

When a user selects an item from the combo box the code will execute and
find the matching record in the clone of the form's underlying recordset.  It
then sets the form's Bookmark property to that of the recordset clone, which
moves the form to the first matching contractID.

You can add an extra refinement by putting the following in the form's
Current event procedure:

Me.cboFindContract = Me.contractID

This keeps the combo box in sync with the form if the user navigates to a
different contract record with the built in navigation buttons or the
keyboard.

Ken Sheridan
Stafford, England

> hi there,
> I have a combo box in the form header of my main form which I wish to use to
[quoted text clipped - 7 lines]
> many thanks,
> claire rohan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.