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

Popup Form as a Subform

Status
Not open for further replies.

jer007

Technical User
Feb 16, 2004
94
CA
Using: Access 2000

I have a rather large subform that does not properly fit onto the same page as the main form. I was thinking of making the subform a popup form. The problem I'm having is that when I set up the subform as a popup form it doesn't display the correct records like it does when it is set up as a normal subform. I have a one to many relationship between the two tables.

My questions are as follows:

1. Would a popup form be the best solution for this?
2. How would I write the VBA code for the on click command so that the correct record(s) will display in the popup form like it does when it's a subform?

Thank you for the help.
 
If you notice a duplicate posting, I apologize. I was having server errors on my end and didn't realize the post went through.

Once again I apologize for the duplicate posting.
 
jer007,

Here is how I coded my setup, which does exactly what you are looking to do, I think. I give all the credit for this to some of the folks on this site, who pointed out how this is accomplished.

Code begin\Private Sub cmdctpv_Click()
On Error GoTo Err_cmdctpv_Click

'Opens the form frmCTPVResults and assigns it the eventid
'and cartridge id, as linked to the individual record in a 1-1 relationship

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCTPVResults"

stLinkCriteria = "[eventid]=" & "'" & Me![txteventid] & "'"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria

Exit_cmdctpv_Click:
Exit Sub

Err_cmdctpv_Click:
MsgBox Err.Description
Resume Exit_cmdctpv_Click

End Sub
Code end\
Substitute your form name and control names in there. Notice that I have the pop up subform openeing in datasheet view. Good luck,

Joe
 
Thanks Joe,

When I click the command button it doesn't matter what record is selected in my main form, all the records open in my popup/subform.

This is my code:

Code begin\
Private Sub cmdAdminReview_Click()
On Error GoTo Err_cmdAdminReview_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmAdminReview"

stLinkCriteria = "[ApplicationID]=" & "" & Me![txt_ApplicationID] & ""
DoCmd.OpenForm stDocName, acNormal, stLinkCriteria
Exit_cmdAdminReview_Click:
Exit Sub
Err_cmdAdminReview_Click:
MsgBox Err.Description
Resume Exit_cmdAdminReview_Click

End Sub
Code end\
Futher explination is as follows:

1.)txt_ApplicationID is the primary key and an autonumber in tblApplication.ApplicationID
2.)there is a one-many relationship between tblApplication.ApplicationID and tblAdminreview.AdminreviewID

When I click the command button I want it to only show the records that meet the 1-many relationship. Currently it is opening all the records.

I think my error is in the line of code begining with "stLinkCriteria = " I'm not understanding what's happening there so I'm not sure if I've coded it correctly.

If you know what I'm doing wrong and can help it would be appriciated.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top