Need Subform to open in a Subform window...

bmhuettinger

Registered User.
Local time
Today, 11:54
Joined
Jul 28, 2017
Messages
59
Good afternoon all!
The following code works exactly as I need it to - by double clicking a master form, I can open and populate fields on a child form. The problem is that the code is telling the form to open in a new window, and I'd like to just open in the subform window (I don't want to see the subform until I open it). A visible=true event doesn't help me.

Private Sub TagNumber_DblClick(Cancel As Integer)
DoCmd.OpenForm "frm_IPOAllocationWorksheet", acNormal
DoCmd.GoToRecord , , acNewRec
Forms!frm_IPOAllocationWorksheet.TagNumber = Me.TagNumber
Forms!frm_IPOAllocationWorksheet.Net = Me.Net
Forms!frm_IPOAllocationWorksheet.IPONumber.SetFocus
End Sub
 
Why doesn't setting visible = true help you? If the subform exists on the form but is hidden, that's the way to make it visible. OpenForm is going to do exactly that, open a form. Another alternative is setting the source object property of a subform control.
 
Thanks for the reply!
Are you suggesting that I change the DoCmd.OpenForm part of my code to visible=true? It's not working for me so I think I'm missing something. Would it possible for you to show me which part of my code needs to be modified?

Private Sub TagNumber_DblClick(Cancel As Integer)
DoCmd.OpenForm "frm_IPOAllocationWorksheet", acNormal
DoCmd.GoToRecord , , acNewRec
Forms!frm_IPOAllocationWorksheet.TagNumber = Me.TagNumber
Forms!frm_IPOAllocationWorksheet.Net = Me.Net
Forms!frm_IPOAllocationWorksheet.IPONumber.SetFocus
End Sub
 
Yes, presuming the subform exists and is not visible to start.

Me.SubformControlName.Visible = True
 
ok - the problem that I have is that when I replace the OpenForm command with visible=true, I get an error message that says "you can't go to the specified record".
If I switch the code back to OpenForm, it works again.
 
Thank you for reply. I'm really not a total novice when it comes to Access but this little subform is causing me a lot of problems. Per your suggestion, I've renamed this form (and all of my subforms) to sfrm_xxxxxx. I deleted the subform entirely, and made sure that it was, in fact, appearing as a subform within my subform, not just floating around on the main form. Two things are happening that I cannot solve.
1. Me.sfrm_IPOAllocationWorksheet.Visible = True, doesn't give me errors but it still seems to be preventing the next line of the code - DoCmd.GoToRecord,,,acNewRec - from working ("cannot go to specific record")
2. even the the subform properties is set to Visible=No, I can still see it.

I'm very frustrated that something that's seemingly so simple is turning out to be so complicated...I have several instances throughout my DB where pop-up subforms work just fine????
 
I understand that forms become subforms when they are added to mainforms. As I mentioned, my DB is filled with them and I've never had this issue. I also don't think that I'm confused about pop-up forms (but anything is possible) - "my" pop-up forms are forms that are hidden until I double-click certain main form controls and remain visible until I click the pop-up forms and then they disappear. Are these not subforms, too?
I know that a major source of confusion for me comes from calling subforms properly in VBA (I often forget to reference the mainform first before references the subform and, specifically, the subform controls.
I honestly don't believe that is my issue here.
What I'm actually trying to do, is open, and populate a FORM (preferably not as a subform) just not in its own window. Imagine a long, "To Do List" tablet that I'd like to "float" over my mainform for a moment, while I need it, then click it and have it go away until I need it again.
I'm so close but every change that improves one issue, seems to undo a previous solution.
 
Hi

If you want the subform to go to a new record based on the record you have selected in the Main Form then you are going to have to pupulate the Foreign Key in the Subform using Open Args
 
..
1. Me.sfrm_IPOAllocationWorksheet.Visible = True, doesn't give me errors but it still seems to be preventing the next line of the code - DoCmd.GoToRecord,,,acNewRec - from working ("cannot go to specific record")
..
Does the form have the focus?
What happen if you comment out that code line?
Are you able to manually append a new record, when the form open?
Could you post a stripped down version of your database with some sample data + a description how to reproduce the problem you've?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom