Blank screen opening empty record form

jomuir

Registered User.
Local time
Today, 19:47
Joined
Feb 13, 2007
Messages
154
I have a main form with a subform that is shown in data format due to the number of fields. I have a button that opens the subform in form view to enable the data to be seen all at once and in a nicer format. This all works well, however as the sub form is not editable and you cannot create a new record via the sub form I have come across a problem!!

When you click on the button (I do not know why anyone would) and there are no records available in the subform - the form opens as just a white area, it does not show an empty record, just white!! How can I change my code to open a popup saying no records or something to prevent this opening when no records are available?

Here is my code of the button:-

Private Sub CmdOpenSubFrmAppData_Click()
On Error GoTo Err_CmdOpenSubFrmAppData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "subfrmAppData"

stLinkCriteria = "[ServerName] = " & """" & Me.[ServerName] & """"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_CmdOpenSubFrmAppData_Click:
Exit Sub

Err_CmdOpenSubFrmAppData_Click:
MsgBox Err.Description
Resume Exit_CmdOpenSubFrmAppData_Click

End Sub
 
Last edited:
Me.RecordSet.RecordCount = 0 Tells you there are no records. You could test for this in the OnLoad event of the form and put up a MsgBox
 
its awkward this - if you disallow additons and have no records, you get a blank field, and you cant even test the values of fields in the subform - everything is just undefined
sometimes this produces strange side effects in the form headers also.

the only thing you might be able to do is set the sub form background with a watermark/image that shows "No Records", which gets covered by data in normal circumstances
 

Users who are viewing this thread

Back
Top Bottom