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

Open linked form as a pop up instead of subform

Status
Not open for further replies.

weezles

Technical User
Jul 18, 2003
81
GB
hi

I'm out of space on my form and would like to open my continuous subform as a popup instead. What is the best way to do this?

I tried using the following code:

Code:
strCriteria = "[RefID]= " & Me.[RefID]
    

DoCmd.OpenForm "frmSub", , , strCriteria

If Forms!frmParent!RefID <> Forms!frmChild!RefID Then
    Forms!frmParent!RefID = Forms!frmChild!RefID
End If

This sometimes allows you to enter the first record, if you want to add another record it sets the ID to 0.

Am I going about this the completely wrong way?

Help

Lou
 
if indeed the form you want to open is frmsub then there
nothing wrong with the way you are opening the form but I question what frmparent and form child are doing here if that is correct and if I understand what you are attempting here there are several optionsa few are:

1. when opening set the default value to the refid then the id will be carried over
me.openargs = "'" & refid & "'"
2. pass the refid as open args then in the openargs then in the on current event
if me.openargs >"" then me.refid = me.openargs



 
Are you adding information to both the main form-subform and having a popup or are you just taking the subform as a whole & making it a popup form?

I am not sure this is the 'best way, but in my current DB project I have combinations of main form, subforms, and popup forms (high number of fields from a variety of related tables). Some of which are continued record info from another form and some are just connected to the main form, but consist of their own table info.

For each, I put a button on the main form that has the following code behind it:
Private Sub {ButtonName}_Click()
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm "{Popup Form Name}"
End Sub

When I continued the main form info onto a popup, I based the pop up on a query (consisting of the main table info that is on the popup form and the Primary Key ID field). Then in the criteria for popup form query PK ID I put: [Forms]![Your Main Form Name]![PK ID] - this way the popup is connected& only opens with data related to the record open on the main form.

If the popup has data that is continued from a subform on the main form, I used: [Forms]![Main Form Name]![subform Name].[Form]![Subform KP ID] in the query based on the subform table and main table ID field.

If the popup was linked to the main form, but was used as a way to capture info for a different table (joined to the main table via a one-many join), I made the record source for the popup a query of limited main form table info (connected via query by the ID field as mentioned above), added a textbox that displayed the main record 'name' (so users could know at a glance what record they were viewing), and then added a subform to it consisting of the many side table - in order to add any number of records to the connected table.

If you are good at VBA, there may be a better way, I am still learning on that level.



 
How are ya weezles . . . . .

Have a look here: How to Synchronize Forms . . . Your Way!

Calvin.gif
See Ya! . . . . . .
 
Thanks Gol4

I set the default value of the ID field in the child form to that of the ID in the parent form.

The code within the if statement was supposed to set the RefID to that of the parent form. When a record didn't exist in the sub form for that particular record it opened with zero as the ID.

The names frmsub/frmchild referred to the same thing, my mistake!

Thanks again

Lou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top