syncronizing forms

D

dmc

hi
I want to synchronize two forms that have the same record source one
data sheet the other single form in an unbound form
I used this code in the load event
Set ajobs_sht.Form.Recordset = ajobs_form.Form.Recordset
I'm getting run time error 424
object needed
i'm using access 2003
is there another way to do it? or can it be fixed
thanks
 
T

Tom van Stiphout

On Fri, 12 Dec 2008 05:22:48 -0800 (PST), dmc <[email protected]>
wrote:

Access 2007 has a new form type called Split Form that can do this in
a single form. Can you upgrade?

If not, write your code in the Form_Current event. Load only fires
when a form is opened; you want your sync code to fire any time the
user moves to another record.
'air code follows
dim f2 as form
set f2 = forms!TheOtherFormName
dim lngPKvalue as long 'assuming you have a numeric PK
lngPKvalue = Me!ThePKField
with f2.RecordsetClone
.Find "ThePkField=" & lngPKValue
debug.assert not .NoMatch 'should never fire if both forms have same
RecordSource
f2.Bookmark = .Bookmark
end with
set f2 = nothing
(of course you need to replace the fake object names with your object
names)

You can put this code in both forms so you can move to another record
on the one, and the other will follow. The strategy used is to set the
form's bookmark equal to the recordsetclone's bookmark.

-Tom.
Microsoft Access MVP
 
D

dmc

Access 2007 has a new form type called Split Form that can do this in
a single form. Can you upgrade?

If not, write your code in the Form_Current event. Load only fires
when a form is opened; you want your sync code to fire any time the
user moves to another record.
'air code follows
dim f2 as form
set f2 = forms!TheOtherFormName
dim lngPKvalue as long 'assuming you have a numeric PK
lngPKvalue = Me!ThePKField
with f2.RecordsetClone
.Find "ThePkField=" & lngPKValue
debug.assert not .NoMatch 'should never fire if both forms have same
RecordSource
f2.Bookmark = .Bookmark
end with
set f2 = nothing
(of course you need to replace the fake object names with your object
names)

You can put this code in both forms so you can move to another record
on the one, and the other will follow. The strategy used is to set the
form's bookmark equal to the recordsetclone's bookmark.

-Tom.
Microsoft Access MVP

thanks a lot
can i relate the single form to another form and keep the old forms
synchronized in the same time?
 
T

Tom van Stiphout

On Fri, 12 Dec 2008 06:15:23 -0800 (PST), dmc <[email protected]>
wrote:

I don't understand your question.
You can put my code in any form you like, and adjust "f2" to be any
form you want to synchronize.
If you want to synchronize several forms to the current form, you need
to expand my code with f3, f4, etc.

HTH,

-Tom.
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top