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 / Forms / May 2007

Tip: Looking for answers? Try searching our database.

Selecting a value in a list box to be used in a query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Supynuts - 14 May 2007 20:29 GMT
I would like my users to choose a value from a list box that gets entered
into the field of a query.  For example, a record is pulled by a 4 digit ID,
yet to see the progress of sales for this ID, many months need to be scrolled
through are compared to the current month (which is held static on the form).
I would rather them select from a box the month they want to compare and
have the fields be populated in the forms bound controls.  What is the best
way to do this?  I tried having the criteria of the query look to the control
on the form, but it doesn't allow the form to open without requesting the
parameter value first...I want the user to be able to see the form and choose
from the list box instead.  

Thanks for the assistnace in advance
Carl Rapson - 14 May 2007 21:47 GMT
>I would like my users to choose a value from a list box that gets entered
> into the field of a query.  For example, a record is pulled by a 4 digit
[quoted text clipped - 14 lines]
>
> Thanks for the assistnace in advance

Remove the criteria from the query (I assume this is the query that the form
is based on). In the AfterUpdate event of the listbox, change the form's
Record Source property to incorporate the month selection:

   Me.RecordSource = "SELECT * FROM [query] WHERE [month]=" & listbox

At any point, if you want to restore the form's Record Source to the full
(unfiltered) query, just set it again:

   Me.RecordSource = "SELECT * FROM [query]"

Carl Rapson
 
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.