[AccessD] Combo Box Question

Arthur Fuller fuller.artful at gmail.com
Wed Feb 12 05:46:40 CST 2014


Chester,

In situations like this, I often make the data source a union query. For
example:

SELECT WellNumber, WellName FROM Wells
UNION
SELECT 0, "All Wells"

At the moment I've forgotten, but I you might need to reverse the order of
the SELECT statements to ensure that the "All Wells" value is at the top.
At any rate, then you just use the code as suggested by Steve, and you're
good to go.

Arthur


On Wed, Feb 12, 2014 at 3:26 AM, Steve Schapel <
steve at datamanagementsolutions.biz> wrote:

> Hi Chester
>
> What is the value of the first (all wells) item in the combobox?  Would it
> work for you to just set that as the Default Value of the combobox, rather
> than using that Form_Open code?  And would it work for you to just use that
> to determine the report?  If I understand you correctly, I would not myself
> favour using the Click event of the combobox to run the report anyway.
> Maybe a little button on the form, to run the report?  That way, the 'all
> wells' option is the default, otherwise the user selects another item from
> the combobox.  And your code on the Click event of the command button along
> the lines of:
>
> Private Sub YourButton_Click()
>    If Me.WellNumber = "all wells" Then        ' (or whatever the value of
> the combobox)
>
>         DoCmd.OpenReport "rpt Set Down All"
>    Else
>         DoCmd.OpenReport "rpt Set Down in a Time Interval"
>    End If
> End Sub
>
> Regards
> Steve


More information about the AccessD mailing list