Can have code like this behind a form but not a subform.
Code:
Private Sub Form_Load()
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "No records"
DoCmd.Close acForm, Me.Name
End If
End Sub
Better would be menu/switchboard form (or a navigation form, which I have never used) with buttons that will open the forms with macro or VBA code. The current setup requires opening the form directly from the navigation pane. The menu form would be set to open by default when the project opens.
You are also using query input parameter prompts. I never use those because cannot validate user input. Better to use forms with controls for user input of search/filter criteria then query parameters refer to the form controls for input. Entries to controls can be validated by code and properties.
Suggest you review some working projects to get an understanding of this structure. Check out the templates available from MS and other sources. A well-known one is the Northwind database. It is used extensively in tutorials.
Check out some of the video tutorials at http://datapigtechnologies.com/AccessMain.htm