Select Case, please help

  • Thread starter Thread starter Gina Whipp
  • Start date Start date
G

Gina Whipp

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
 
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???

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]
 
John,

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top