Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MY FORM IS BLANK. HELP PLEASE

Status
Not open for further replies.

regava

Programmer
May 24, 2001
152
0
0
US
I have a form that is boung to an underlying record source that may or may not have data. When there is data, no problem. However, when there is not data I get a blank Window (nothing is displayed.) I would like to catch this situation on time and issued a message that there is no data to display at this time. I NEED TO KNOW WHERE/WHEN/HOW TO DO THE APPROPIATE CHECK. Help is appreciated.
Rene
 
Why not On OPEN of the form check for data and if there is none display a message?


Joanne
 
Try this on the OnOpen event of your form.

Private Sub Form_Open(Cancel As Integer)
Dim Db As Database
Dim recR As Recordset

Set Db = CurrentDb()
Set recR = Db.OpenRecordset("YOUR TABLE", dbOpenTable)

With recR
If .RecordCount > 1 Then
MsgBox "There is no data to view.", , ""
DoCmd.Close acForm, "YOUR FORM"
Exit Sub
End If
End With
End Sub

Hope it helps.
 
Ooops the line:

If .RecordCount > 1 Then

should read:

If .RecordCount < 1

Sorry!
 
Joanne thank you. I did what you suggested. It seems to be the right place. However, Whenever I tried to check for data in one of the form's field I get the following error message: &quot;RUNTIME ERROR 2427: YOU ENTERED AN EXPRESSION THAT HAS NO VALUE&quot; Any sugestions.
Rene.
 
I am very sorry. I just realized that I neglected to mention in my original posting that the records being pulled from the table are based on a condition. The table always has records. In some cases the condition is not met and there is when the form goes blank. Any sugestion?
Thank you. Rene.
 
Well check and see if that condition has a value if not to get the form to display is there anyway you can default values to show a template form or is this what you want to do?

Joanne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top