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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subforms missing when adding new record

Status
Not open for further replies.

Janet95

Technical User
Jun 6, 2006
45
US
Hi,
I have a form with multiple tabs. Each tab page has a sub form within it. Every time I go to add a record the sub forms are missing.

This worked at one point.

I checked the Sub form Field Linder properties, which link the child and master fields between the form and they seem ok.

Any suggestions would be greatly appreciated.

Thanks so much in advance.[ponytails2]
 
When you say 'missing' do you mean that there is no subform at all, or that there is no way of entering data? If it is that there is no way of entering data, have you checked the Allow Additions property of the subform?
 
Hi,
the sub form is not there at all. I can't even see it.
I did check the Allow Additions property of the subform and they were set to no so I set it to yes and it still doesn't work.
The sub forms are invisible. They are there when I scroll through existing records.


 
Is there any code associated with form or subform?
 
Yes
on the add command button
Code:
Private Sub cmd_AddRecord_Click()
On Error GoTo Err_cmd_AddRecord_Click

    Me.AllowEdits = True
    Me.AllowAdditions = True
    Me.NavigationButtons = False
    Me.cmd_EditRecord.Enabled = False
    Me.cmd_DeleteRecord.Enabled = False
    'Me.cmdOpenPartnerProfile.Enabled = False
    Forms![frmDivaProfile]![diva_employment subform].Form.AllowEdits = True
    Forms![frmDivaProfile]![diva_descripters SubForm].Form.AllowEdits = True
    Forms![frmDivaProfile]![diva_church subform].Form.AllowEdits = True
    Forms![frmDivaProfile]![diva_adjectives subform].Form.AllowEdits = True
    Forms![frmDivaProfile]![diva_favorite dress subform].Form.AllowEdits = True
    Forms![frmDivaProfile]![diva_favorite foods subform].Form.AllowEdits = True
    Forms![frmDivaProfile]![diva_favorite dress subform].Form.AllowEdits = True
    Forms![frmDivaProfile]![diva_places subform].Form.AllowEdits = True
    Forms![frmDivaProfile]![diva_creditcard subform].Form.AllowEdits = True
    
    
    
    
    
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.AllowEdits = False
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.AllowAdditions = True
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.cmd_AddRecord.Visible = True
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.cmd_EditRecord.Visible = True
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.cmd_DeleteRecord.Visible = True
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.cmd_SaveRecord.Visible = True
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.cmd_AddRecord.Enabled = False
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.cmd_EditRecord.Enabled = False
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.cmd_DeleteRecord.Enabled = True
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.cmd_SaveRecord.Enabled = True
  
 
    
       
    
    Forms![frmDivaProfile]![partnerLinkSubform].Form.AllowEdits = False
    Forms![frmDivaProfile]![partnerLinkSubform].Form.AllowAdditions = True
    
    
    Forms![frmDivaProfile]![partnerLinkSubform].Form.cmd_AddRecord.Visible = True
    Forms![frmDivaProfile]![partnerLinkSubform].Form.cmd_EditRecord.Visible = True
    Forms![frmDivaProfile]![partnerLinkSubform].Form.cmd_DeleteRecord.Visible = True
    Forms![frmDivaProfile]![partnerLinkSubform].Form.cmd_SaveRecord.Visible = True
    
    Forms![frmDivaProfile]![partnerLinkSubform].Form.cmd_AddRecord.Enabled = False
    Forms![frmDivaProfile]![partnerLinkSubform].Form.cmd_EditRecord.Enabled = False
    Forms![frmDivaProfile]![partnerLinkSubform].Form.cmd_DeleteRecord.Enabled = True
    Forms![frmDivaProfile]![partnerLinkSubform].Form.cmd_SaveRecord.Enabled = True
    
    DoCmd.GoToRecord , , acNewRec
    
    Me.txtsetfocus2.SetFocus
    Me.txtsetfocus3.SetFocus
    Me.txtsetfocus4.SetFocus
    Me.txtsetfocus1.SetFocus
    
    Me.txtSignUpDate.SetFocus
    Me.cmd_SaveRecord.Enabled = True
    Me.cmd_AddRecord.Enabled = False
    Me.Refresh
    
Exit_cmd_AddRecord_Click:
    Exit Sub

Err_cmd_AddRecord_Click:
    MsgBox Err.Description
    Resume Exit_cmd_AddRecord_Click
End Sub

and on the on open event for the main form
Code:
Private Sub Form_Open(Cancel As Integer)
    Me.AllowEdits = False
    
    Me.cmd_AddRecord.Enabled = True
    Me.cmd_EditRecord.Enabled = True
    Me.cmd_DeleteRecord.Enabled = True
    Me.cmd_SaveRecord.Enabled = False
    
    Forms![frmDivaProfile]![diva_employment subform].Form.AllowEdits = False
    Forms![frmDivaProfile]![diva_descripters SubForm].Form.AllowEdits = False
    Forms![frmDivaProfile]![diva_church subform].Form.AllowEdits = False
    Forms![frmDivaProfile]![diva_adjectives subform].Form.AllowEdits = False
    Forms![frmDivaProfile]![diva_favorite dress subform].Form.AllowEdits = False
    Forms![frmDivaProfile]![diva_favorite foods subform].Form.AllowEdits = False
    Forms![frmDivaProfile]![diva_favorite dress subform].Form.AllowEdits = False
    Forms![frmDivaProfile]![diva_places subform].Form.AllowEdits = False
    Forms![frmDivaProfile]![diva_creditcard subform].Form.AllowEdits = False
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.AllowEdits = False
    'Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.AllowAddition = False
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.cmd_AddRecord.Visible = False
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.cmd_EditRecord.Visible = False
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.cmd_DeleteRecord.Visible = False
    Forms![frmDivaProfile]![tblAccountsPaybleDiva Subformwiz].Form.cmd_SaveRecord.Visible = False
    
   
    Forms![frmDivaProfile]![partnerLinkSubform].Form.AllowEdits = False
    Forms![frmDivaProfile]![partnerLinkSubform].Form.AllowAdditions = False
    
    
    Forms![frmDivaProfile]![partnerLinkSubform].Form.cmd_AddRecord.Visible = False
    Forms![frmDivaProfile]![partnerLinkSubform].Form.cmd_EditRecord.Visible = False
    Forms![frmDivaProfile]![partnerLinkSubform].Form.cmd_DeleteRecord.Visible = False
    Forms![frmDivaProfile]![partnerLinkSubform].Form.cmd_SaveRecord.Visible = False
    
    Me.txtsetfocus2.SetFocus
    Me.txtsetfocus3.SetFocus
    Me.txtsetfocus4.SetFocus
    Me.txtsetfocus1.SetFocus
    
    
    Me.Refresh
    
End Sub
 
but these are the same for the working and non-working versions of the database. I have a previous version of the database that all the sub forms work fine in. I can't figure out what has changed. I have added new fields to some of the sub-forms and changed the visual layout, but that shouldn't make a difference.
 
I cannot reproduce the problem. It is quite common to get a subform that does not allow data entry, but in that case, the headers can be seen, the subform does not vanish completely. All I can suggest is a few message boxes or debug.prints that will show what is happening. For example:
[tt]MsgBox Forms![frmDivaProfile]![diva_employment subform].Form.Name
MsgBox Forms![frmDivaProfile]![diva_employment subform].Form.RecordsetClone.RecordCount[/tt]

I would have thought that you would have On Current code, also, the four 'set focuses' have me a little confused as they do not seem to have a point.
 
Yes the 4 set focuses are a pain, they where there to test another issue.

I'm at a loss, not sure what else to do or try.
 
How about importing the 'working' forms into a copy of the 'not working' database? This would show if it is some change in the data or some change in the form{s). It would be quite easy to check each of the properties for 'working' and 'not working' using code, if you find that 'working' forms still work in the 'not working' database. [ponder]
 
OK, I just tried that. I took the non-working database and imported the working form. Just the main form. I left all of the sub forms in the non-working database alone. When I opened up the working form in the non-working database it worked. Do you think I should just take the working form and make all the hundreds of little changes I made to the non-working form until I figure out what broke it or it there an easier way?
 
I reckon there are probably only four areas that need to be checked and they are:
- Main form properties: Allow Additions, Allow Edits, Data Entry
- Main form Data Source
- Link Child and Master fields for one subform
- Main form code, which can be compared line by line with code or by pasting into Word or Excel for example.


 
Hi Remou,

I truly appreciate all of your help.

The first tab/page on the main form has most of the changes that I made since the working version and non-working version, so what I'm attempted to do now is take the working version and cut the fields out of the first tab/page from the non-working version and past them into the working version. I think this should do the trick nice and simple. This process and tweeking should take me the next few hours. I'll let you know how it went tommorow.

Again, I've very appreicative of all of your help. Its nice to know there are people out there willing to lend a hand.
 
Hi Remou,

That worked!!![2thumbsup]
Thanks again for your help [peace]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top