Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 23rd, 2007, 04:12 AM
Authorized User
 
Join Date: Jun 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Forms/SubForms

When I have used a sub form within a form, I have usually used a query or table and that has enabled me to bound objects together, this time I am using a table or query from another database. All my objects are now unbound and from the Open_Form() I load in the query or table using SQL.
How is it possible to use the linking of Master & Child fields?

Jez

 
Old July 23rd, 2007, 07:11 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Add the link as a parameter in the Row Source property for the subform, like:

Dim iPrimaryKey As Integer
Dim sSQL As String

iPrimaryKey = Me.PK 'from the main form.

sSQL = "SELECT * FROM tblMySubFormTable WHERE [FK] = " & iPrimaryKey

etc.

Did that help any? You can out this on the On Current event and others on the main form.


mmcdonal
 
Old July 23rd, 2007, 08:59 AM
Authorized User
 
Join Date: Jun 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

mmcdonal,Thanks for the reply but am a little unsure what it means.
Is this SQL above written into the Form_Current() event on the subform, or is it written into the main form?

I have also tried that iPrimaryKey = me.PK before and am having problems with that as in the thread ComboBox_GotFocus()

Jez







Similar Threads
Thread Thread Starter Forum Replies Last Post
Subforms 150563a Access 1 June 29th, 2007 04:57 AM
Edit Forms with Master/Multiple SubForms natwong Access 1 February 27th, 2007 01:01 PM
Forms and Subforms auskermit Access 2 June 26th, 2006 06:02 PM
subforms ajmil11 Access 2 January 19th, 2006 11:16 PM
Subforms V Access VBA 1 April 21st, 2004 11:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.