PC Review


Reply
Thread Tools Rate Thread

GoToRecord on a subform...

 
 
John Keith
Guest
Posts: n/a
 
      22nd Jan 2009
How do I give the string name of a subform in the following:
DoCmd.GoToRecord acDataForm, "Subform name string", acGoTo, recnum

Or if this is not possible, here is what I am trying...

I have 3 forms,
Subform A is a continuous form w/ Name and Title only (onClick routines
position the form B record).
Form B includes Subform A and has all fields for one row.
Popup Data Entry form C is modal, has all fields for adding data.
All 3 have the same underlying updatable query.

Main form A/B allows clicking on a row in A which selects that row and
displays it in the fields of B.
A/B has an Add button and a Delete button.

When adding, an input box asks for the key and if that key already exists
then B shows that record. Otherwise C pops up to add new data. Once C is
closed, the data is committed and Form A/B gets focus w/ B showing the new
record.

In each case above, I'd like to make the subform also GoTo that record.

What are some alternatives?
I did try to swap A and B but a "continous" main form can not have a sub-form.

--
Regards,
John
 
Reply With Quote
 
 
 
 
Marshall Barton
Guest
Posts: n/a
 
      23rd Jan 2009
John Keith wrote:

>How do I give the string name of a subform in the following:
>DoCmd.GoToRecord acDataForm, "Subform name string", acGoTo, recnum
>
>Or if this is not possible, here is what I am trying...
>
>I have 3 forms,
>Subform A is a continuous form w/ Name and Title only (onClick routines
>position the form B record).
>Form B includes Subform A and has all fields for one row.
>Popup Data Entry form C is modal, has all fields for adding data.
>All 3 have the same underlying updatable query.
>
>Main form A/B allows clicking on a row in A which selects that row and
>displays it in the fields of B.
>A/B has an Add button and a Delete button.
>
>When adding, an input box asks for the key and if that key already exists
>then B shows that record. Otherwise C pops up to add new data. Once C is
>closed, the data is committed and Form A/B gets focus w/ B showing the new
>record.
>
>In each case above, I'd like to make the subform also GoTo that record.



A lot of the DoCmd operations are limited in their ability
to manipulate specific objects. In this case you can use
the LinkMaster/Child properties to sync the two subforms.

Add a hidden text box (named txtLinkA) to the main form.
Then add a line of code to subformA's Current event
procedre:
Parent.txtLinkA = Me.[the primary key field name]

Now set the subformB control's LinkMasterFields property to
txtLinkA and set the LinkChildFields property to the primary
key field name.

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
 
 
 
John Keith
Guest
Posts: n/a
 
      23rd Jan 2009
Thanks for the reply:

I tried linking the form/sub-form via the master/child properties but this
caused an undesired effect. It forced the continous sub-form to filter to
the main form's single record.

I discovered that I did not need an explicit gotorecord for the sub form.
All that was required was to position the record set then the sub-form
automatically positioned itself.

In Form C's btnAdd_Click routine after the newSSN has been stored using the
Close form action. F is a ref to formB and SF is a ref to sub-formA:

F.Requery
SF.Requery
F.Recordset.FindFirst ("[SSN] = '" & NewSSN & "'")
DoCmd.GoToRecord acDataForm, "Empl", acGoTo, F.Recordset.AbsolutePosition
+ 1
SF.Recordset.FindFirst ("[SSN] = '" & NewSSN & "'")

I am wondering if there is a trick to using the link fields that will
preserve the continous feature of the sub-form. Perhaps this way could get
around having to requery the recordsets.

--
Regards,
John


"Marshall Barton" wrote:

> John Keith wrote:
>
> >How do I give the string name of a subform in the following:
> >DoCmd.GoToRecord acDataForm, "Subform name string", acGoTo, recnum
> >
> >Or if this is not possible, here is what I am trying...
> >
> >I have 3 forms,
> >Subform A is a continuous form w/ Name and Title only (onClick routines
> >position the form B record).
> >Form B includes Subform A and has all fields for one row.
> >Popup Data Entry form C is modal, has all fields for adding data.
> >All 3 have the same underlying updatable query.
> >
> >Main form A/B allows clicking on a row in A which selects that row and
> >displays it in the fields of B.
> >A/B has an Add button and a Delete button.
> >
> >When adding, an input box asks for the key and if that key already exists
> >then B shows that record. Otherwise C pops up to add new data. Once C is
> >closed, the data is committed and Form A/B gets focus w/ B showing the new
> >record.
> >
> >In each case above, I'd like to make the subform also GoTo that record.

>
>
> A lot of the DoCmd operations are limited in their ability
> to manipulate specific objects. In this case you can use
> the LinkMaster/Child properties to sync the two subforms.
>
> Add a hidden text box (named txtLinkA) to the main form.
> Then add a line of code to subformA's Current event
> procedre:
> Parent.txtLinkA = Me.[the primary key field name]
>
> Now set the subformB control's LinkMasterFields property to
> txtLinkA and set the LinkChildFields property to the primary
> key field name.
>
> --
> Marsh
> MVP [MS Access]
>

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      23rd Jan 2009
John Keith wrote:
>I tried linking the form/sub-form via the master/child properties but this
>caused an undesired effect. It forced the continous sub-form to filter to
>the main form's single record.
>
>I discovered that I did not need an explicit gotorecord for the sub form.
>All that was required was to position the record set then the sub-form
>automatically positioned itself.
>
>In Form C's btnAdd_Click routine after the newSSN has been stored using the
>Close form action. F is a ref to formB and SF is a ref to sub-formA:
>
> F.Requery
> SF.Requery
> F.Recordset.FindFirst ("[SSN] = '" & NewSSN & "'")
> DoCmd.GoToRecord acDataForm, "Empl", acGoTo, F.Recordset.AbsolutePosition
>+ 1
> SF.Recordset.FindFirst ("[SSN] = '" & NewSSN & "'")
>
>I am wondering if there is a trick to using the link fields that will
>preserve the continous feature of the sub-form. Perhaps this way could get
>around having to requery the recordsets.



Use the LinkMaster/Child links of the single subform (B),
not the continuous subform (A)

The requeries are needed to pick up a new/edited record.

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DoCmd.GotoRecord blah blah OFFSET Hugh Horton Microsoft Access 2 5th May 2004 09:36 AM
GotoRecord? Henro Microsoft Access 2 28th Jan 2004 07:20 PM
Access 2002/XP - DoCmd.GoToRecord does not work correctly Aldo Gautschi Microsoft Access 1 20th Oct 2003 02:09 AM
GoToRecord Action Ginger Microsoft Access Forms 13 21st Aug 2003 12:57 AM
error after "gotorecord" repeats 390 times Scott Microsoft Access Forms 5 28th Jul 2003 12:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:53 PM.