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