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 / General 2 / May 2007

Tip: Looking for answers? Try searching our database.

Select Case, please help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gina Whipp - 31 May 2007 05:53 GMT
Hello All,

Below I have a Select Case statement.  All is well except when there is No
Data in a particular query then the form blanks out and you can't even make
another selection.  I would like to create a message and then have the form
remain available to make another selection.  No matter what I try I can get
a message, so perhaps I am not doing it right.  Any ideas???

Select Case cboDocumentName
       Case "Got Your Referral"
           Me.RecordSource = "qryGotReferral"
           Me!cboCustomerID.RowSource = "SELECT qryGotReferral.CUSTOMERNBR,
qryGotReferral.NAME FROM qryGotReferral GROUP BY qryGotReferral.CUSTOMERNBR,
qryGotReferral.NAME;"
       Case "No Rewards Letter"
           Me.RecordSource = "qryNoReward"
           Me!cboCustomerID.RowSource = "SELECT qryNoReward.CUSTOMERNBR,
qryNoReward.NAME FROM qryNoReward GROUP BY qryNoReward.CUSTOMERNBR,
qryNoReward.NAME;"
       Case "The Money Letter"
           Me.RecordSource = "qrySold"
           Me!cboCustomerID.RowSource = "SELECT qrySold.CUSTOMERNBR,
qrySold.NAME FROM qrySold GROUP BY qrySold.CUSTOMERNBR, qrySold.NAME;"
   End Select

Thanks for any help you can give...
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II
John W. Vinson - 31 May 2007 06:35 GMT
>Hello All,
>
[quoted text clipped - 3 lines]
>remain available to make another selection.  No matter what I try I can get
>a message, so perhaps I am not doing it right.  Any ideas???

So if qrySold happens to return no records...?

Try checking the query to see if it has records first. Add

Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb

before the executable statements, then open a recordset based on the query:
e.g.

    Set rs = db.OpenRecordset("qrySold")
    If rs.Recordcount = 0 Then
        Msgbox "No data found!"
    Else
                 Me.RecordSource = "qrySold"
            End If
    rs.Close
    set rs = Nothing

and similarly for the other queries.

            John W. Vinson [MVP]
Gina Whipp - 31 May 2007 06:42 GMT
Are you sying I should abandon my Select Case?  Probably better anyway...

Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

> On Thu, 31 May 2007 00:53:56 -0400, "Gina Whipp"
> <NotInterested@InViruses.com>
[quoted text clipped - 35 lines]
>
>             John W. Vinson [MVP]
Gina Whipp - 31 May 2007 06:51 GMT
John,

I think I misunderstood.  I have never tried to open 3 seperate recordsets
in one AfterUpdate event, please explain...

Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

> On Thu, 31 May 2007 00:53:56 -0400, "Gina Whipp"
> <NotInterested@InViruses.com>
[quoted text clipped - 35 lines]
>
>             John W. Vinson [MVP]
Gina Whipp - 31 May 2007 06:57 GMT
Okay, I'm slow... I got it  big THANKS!!!!

Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

> On Thu, 31 May 2007 00:53:56 -0400, "Gina Whipp"
> <NotInterested@InViruses.com>
[quoted text clipped - 35 lines]
>
>             John W. Vinson [MVP]
John W. Vinson - 31 May 2007 16:56 GMT
> I got it  big THANKS!!!!

You're welcome, Gina!

            John W. Vinson [MVP]
 
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.