Hi,
I have a frmStoreDemographics with subform sfrmStoreDemographicsComments. The link is on the StoreID. The subform is used to enter comments specific that the store that is open on frmStoreDemographics. This works fine as long as there is at least one corresponding StoreID record in the subform. If there isn't a corresponding StoreID, the subform doesn't open. I would like to have sfrmStoreDemographicsComments go to a new record if there is not a corresponding record. I tried the following code but it doesn't work:
Private Sub Form_Load()
If IsNull(Me.StoreID) Then
DoCmd.GoToRecord , , acNewRec
End If
Thanks,
Leesha
Subform Error
-
- 3StarLounger
- Posts: 287
- Joined: 09 Mar 2010, 23:16
- Location: Canberra Australia
Re: Subform Error
Does the subform display multiple comments each as a separate record, with a storeID as a field in each record?
In that case the subform should always display a new blank record at the end of the existing records, without any code.
Otherwise can you explain the table structure behind these forms?
In that case the subform should always display a new blank record at the end of the existing records, without any code.
Otherwise can you explain the table structure behind these forms?
Regards
John
John
-
- NewLounger
- Posts: 4
- Joined: 06 Mar 2011, 22:30
- Status: Microsoft MVP
Re: Subform Error
Hi Leesha,
Open your subform in design view, and display the Properties dialog for the form (your should see "Form" in the blue title bar of the Properties dialog). Click on the Data tab. Is your Allow Additions property set to No? It needs to be set to Yes to prevent the problem you describe. Also, if you have a saved query or SQL statement that serves as the recordsource for the subform, you need to be able to add new records to this query. Test that your query allows you to add new records.
Open your subform in design view, and display the Properties dialog for the form (your should see "Form" in the blue title bar of the Properties dialog). Click on the Data tab. Is your Allow Additions property set to No? It needs to be set to Yes to prevent the problem you describe. Also, if you have a saved query or SQL statement that serves as the recordsource for the subform, you need to be able to add new records to this query. Test that your query allows you to add new records.
-
- BronzeLounger
- Posts: 1496
- Joined: 05 Feb 2010, 22:25
Re: Subform Error
Jeeze! I can't believe I missed that. The property was set to no for additions and edits!
Thanks so much,
Leesha
Thanks so much,
Leesha