Show dialog if there are no records in a form

C

CAM

Hello,

I am using Access 2002 and I have a very simple form - the datasource is
from a query call "qryCustomer". In my form I have a combo box you can
select a particular customer via parameters from "qryCustomer" and I can
print a report via command button, not problem at all when there is a
record of the customer, but when I select a customer that has no records I
lose all combo box, command button in my form from particular customers I
selected. What I want is a way if there is no record of a customer I don't
lose any of my controls and funcitionality of the form. Can someone help
me? Thank you in advance.

Cheers
 
A

Allen Browne

For an explanation of why you 'lose' all the controls on your form, see:
Why does my form go completely blank?
at:
http://allenbrowne.com/casu-20.html

If your source query is updatable, you may be able to work around the issue
by setting the form's AllowAdditions property to yes, preventing new records
by cancelling its BeforeInsert event instead.

Alternatively, the command button might still work if you put it in the
Form_Header section (provided it is not trying to refer to controls on the
form.)

If the form really is read-only, another option might be to cancel the
form's Open event if there are no records:
Private Sub Form_Open(Cancel As Integer)
If Me.Recordset.RecordCount = 0 Then
Cancel = True
MsgBox "Nothing to show."
End If
End Sub
 

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

Top