Link to home
Start Free TrialLog in
Avatar of Sheogorath
SheogorathFlag for United States of America

asked on

Selecting Dates and displaying related fields via Combobox

Hi I would like to select dates from my table via combo box  and display the related information on the Split form's datasheet.

For example I have the below data in the table:
date                        name                 code
05/01/2011             John Smith          A
05/01/2011             Jane Smith          B
05/15/2011             George Ellis        A
05/15/2011             Jane Smith         K

So when I select from my combobox the date of 05/01/2011 I only would like to see the below information  in the datasheet.

05/01/2011             John Smith          A
05/01/2011             Jane Smith          B


Any help will be greatly appreciated.
Avatar of danishani
danishani
Flag of United States of America image

You can make use of the Filter() property of your Subform, based on your Combox value.

In the AfterUpdate event of your Combobox, try something like this:

Dim strFilter As String

strFilter = "[DateFieldName]=" & Me.ComboboxName

Forms![YourMainFormName]![YourSubFormName].Filter = strFilter

Forms![YourMainFormName]![YourSubFormName].FilterOn = True

HTH,
Daniel
Oops, saw one error in above post, dealing with a Date Field, you need hashes:

Dim strFilter As String

strFilter = "[DateFieldName]=#" & Me.ComboboxName & "#"

Forms![YourMainFormName]![YourSubFormName].Filter = strFilter

Forms![YourMainFormName]![YourSubFormName].FilterOn = True

HTH,
Daniel
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks.

As a follow up, you can simply create a table of all "available" dates, and update it periodically.

You can auto-fill sequential dates in Excel quite easily...

;-)