trying to access recordsetclone from one subform to another.

G

Guest

access 2000

I have a form with 2 subforms. They are on 2 different pages of a tab
control. Lets call the parent [P] and the 2 subforms [sf1] and [sf2]

I am trying resync sf2 on the on current of sf1 but I cant seem to find the
syntax to correctly set a recordset clone object. the following doesnt work.

Private Sub Form_Current() 'of sf1

Dim rst, rst1 As dao.Recordset

rst1 = forms![p]![sf2].recordsetclone
or
rst1 = forms![p]![sf2].form.recordsetclone

Help!
 
M

Marshall Barton

RHC said:
access 2000

I have a form with 2 subforms. They are on 2 different pages of a tab
control. Lets call the parent [P] and the 2 subforms [sf1] and [sf2]

I am trying resync sf2 on the on current of sf1 but I cant seem to find the
syntax to correctly set a recordset clone object. the following doesnt work.

Private Sub Form_Current() 'of sf1

Dim rst, rst1 As dao.Recordset

rst1 = forms![p]![sf2].recordsetclone
or
rst1 = forms![p]![sf2].form.recordsetclone


You must use the Set statement when manipulating object
variables (as opposed to simple value variables). But, I am
not at all sure about your approach.

When the second subform displays details about the current
record in the first subform, I have always used the Link
Master/Child properties to sync the subforms. To do this,
add a hidden text box named txtLink to the main form's
header/footer section. Then set sf2's Link Master Fields
property to txtLink and the Link Child Fields property to
the corresponding field. The code in sf1's Current event
would only need to be:
Parent.txtLink = Me.thelinkingfield
The rest is automatic.
 
D

Douglas J. Steele

In addition to Marshall's advice, be aware that your declaration probably
isn't doing what you think it is.

As written, you're declaring rst1 as a DAO recordset, but rst is being
declared as a variant. VBA doesn't support "short circuiting" in
declarations. Odds are you want

Dim rst As DAO.Recordset, rst1 As DAO.Recordset
 
G

Guest

thanks for your help. sorry typo on my part I am using

set rst1 = forms![p]![sf2].recordsetclone

the question is why doesnt this work.
 
G

Guest

thanks for catching this im getting senile. I still dont understand why
one of set rst1 = forms![P]![sf2].form.recordsetclone or rst1 =
forms![p]![sf2].recordsetclone dont work.



Douglas J. Steele said:
In addition to Marshall's advice, be aware that your declaration probably
isn't doing what you think it is.

As written, you're declaring rst1 as a DAO recordset, but rst is being
declared as a variant. VBA doesn't support "short circuiting" in
declarations. Odds are you want

Dim rst As DAO.Recordset, rst1 As DAO.Recordset


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RHC said:
access 2000

I have a form with 2 subforms. They are on 2 different pages of a tab
control. Lets call the parent [P] and the 2 subforms [sf1] and [sf2]

I am trying resync sf2 on the on current of sf1 but I cant seem to find
the
syntax to correctly set a recordset clone object. the following doesnt
work.

Private Sub Form_Current() 'of sf1

Dim rst, rst1 As dao.Recordset

rst1 = forms![p]![sf2].recordsetclone
or
rst1 = forms![p]![sf2].form.recordsetclone

Help!
 
D

Douglas J. Steele

sf2 must be the name of the subform control on form p: that may or may not
be the same as the name of the form being used as the subform.

If sf2 is the name of the control, then

Set rst1 = forms![p]![sf2].Form.RecordsetClone

should work.

What exactly is, or isn't, happening to lead you to say it doesn't work? Are
you getting an error? If so, what error is it?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RHC said:
thanks for your help. sorry typo on my part I am using

set rst1 = forms![p]![sf2].recordsetclone

the question is why doesnt this work.

RHC said:
access 2000

I have a form with 2 subforms. They are on 2 different pages of a tab
control. Lets call the parent [P] and the 2 subforms [sf1] and [sf2]

I am trying resync sf2 on the on current of sf1 but I cant seem to find
the
syntax to correctly set a recordset clone object. the following doesnt
work.

Private Sub Form_Current() 'of sf1

Dim rst, rst1 As dao.Recordset

rst1 = forms![p]![sf2].recordsetclone
or
rst1 = forms![p]![sf2].form.recordsetclone

Help!
 
G

Guest

i get the error msg You entered an expression that has an invalid reference
to the property Form/Report. I just confirmed that im using the right name
of the subform control and have tried changing it to literally sf2 to no
avail.

Douglas J. Steele said:
sf2 must be the name of the subform control on form p: that may or may not
be the same as the name of the form being used as the subform.

If sf2 is the name of the control, then

Set rst1 = forms![p]![sf2].Form.RecordsetClone

should work.

What exactly is, or isn't, happening to lead you to say it doesn't work? Are
you getting an error? If so, what error is it?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RHC said:
thanks for your help. sorry typo on my part I am using

set rst1 = forms![p]![sf2].recordsetclone

the question is why doesnt this work.

RHC said:
access 2000

I have a form with 2 subforms. They are on 2 different pages of a tab
control. Lets call the parent [P] and the 2 subforms [sf1] and [sf2]

I am trying resync sf2 on the on current of sf1 but I cant seem to find
the
syntax to correctly set a recordset clone object. the following doesnt
work.

Private Sub Form_Current() 'of sf1

Dim rst, rst1 As dao.Recordset

rst1 = forms![p]![sf2].recordsetclone
or
rst1 = forms![p]![sf2].form.recordsetclone

Help!
 
G

Guest

btw this works
MsgBox Forms!P!sf2.Name

Douglas J. Steele said:
sf2 must be the name of the subform control on form p: that may or may not
be the same as the name of the form being used as the subform.

If sf2 is the name of the control, then

Set rst1 = forms![p]![sf2].Form.RecordsetClone

should work.

What exactly is, or isn't, happening to lead you to say it doesn't work? Are
you getting an error? If so, what error is it?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RHC said:
thanks for your help. sorry typo on my part I am using

set rst1 = forms![p]![sf2].recordsetclone

the question is why doesnt this work.

RHC said:
access 2000

I have a form with 2 subforms. They are on 2 different pages of a tab
control. Lets call the parent [P] and the 2 subforms [sf1] and [sf2]

I am trying resync sf2 on the on current of sf1 but I cant seem to find
the
syntax to correctly set a recordset clone object. the following doesnt
work.

Private Sub Form_Current() 'of sf1

Dim rst, rst1 As dao.Recordset

rst1 = forms![p]![sf2].recordsetclone
or
rst1 = forms![p]![sf2].form.recordsetclone

Help!
 
D

Douglas J. Steele

So what happens if you remove the square brackets in your Set statement?

Set rst1 = forms!p!sf2.Form.RecordsetClone

Is that the actual code you're using? The lack of uppercase letters in what
you're posting makes me suspect you're not copying the actual code you're
using into your posts.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RHC said:
btw this works
MsgBox Forms!P!sf2.Name

Douglas J. Steele said:
sf2 must be the name of the subform control on form p: that may or may
not
be the same as the name of the form being used as the subform.

If sf2 is the name of the control, then

Set rst1 = forms![p]![sf2].Form.RecordsetClone

should work.

What exactly is, or isn't, happening to lead you to say it doesn't work?
Are
you getting an error? If so, what error is it?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RHC said:
thanks for your help. sorry typo on my part I am using

set rst1 = forms![p]![sf2].recordsetclone

the question is why doesnt this work.

:

access 2000

I have a form with 2 subforms. They are on 2 different pages of a tab
control. Lets call the parent [P] and the 2 subforms [sf1] and [sf2]

I am trying resync sf2 on the on current of sf1 but I cant seem to
find
the
syntax to correctly set a recordset clone object. the following doesnt
work.

Private Sub Form_Current() 'of sf1

Dim rst, rst1 As dao.Recordset

rst1 = forms![p]![sf2].recordsetclone
or
rst1 = forms![p]![sf2].form.recordsetclone

Help!
 
G

Guest

here is the exact code

Private Sub Form_Current()

Dim rst As dao.Recordset
Dim rst1 As dao.Recordset
Dim l As Long
Dim s As String

On Error GoTo eh

Set rst1 = Forms!Ducali_tab!sf2.Form.RecordsetClone

Ducali_tab is the parent form
The on current event is for sf1 the other subform on Ducali_tab

Douglas J. Steele said:
So what happens if you remove the square brackets in your Set statement?

Set rst1 = forms!p!sf2.Form.RecordsetClone

Is that the actual code you're using? The lack of uppercase letters in what
you're posting makes me suspect you're not copying the actual code you're
using into your posts.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RHC said:
btw this works
MsgBox Forms!P!sf2.Name

Douglas J. Steele said:
sf2 must be the name of the subform control on form p: that may or may
not
be the same as the name of the form being used as the subform.

If sf2 is the name of the control, then

Set rst1 = forms![p]![sf2].Form.RecordsetClone

should work.

What exactly is, or isn't, happening to lead you to say it doesn't work?
Are
you getting an error? If so, what error is it?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


thanks for your help. sorry typo on my part I am using

set rst1 = forms![p]![sf2].recordsetclone

the question is why doesnt this work.

:

access 2000

I have a form with 2 subforms. They are on 2 different pages of a tab
control. Lets call the parent [P] and the 2 subforms [sf1] and [sf2]

I am trying resync sf2 on the on current of sf1 but I cant seem to
find
the
syntax to correctly set a recordset clone object. the following doesnt
work.

Private Sub Form_Current() 'of sf1

Dim rst, rst1 As dao.Recordset

rst1 = forms![p]![sf2].recordsetclone
or
rst1 = forms![p]![sf2].form.recordsetclone

Help!
 
D

Douglas J. Steele

I would expect that to work. What's happening instead?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RHC said:
here is the exact code

Private Sub Form_Current()

Dim rst As dao.Recordset
Dim rst1 As dao.Recordset
Dim l As Long
Dim s As String

On Error GoTo eh

Set rst1 = Forms!Ducali_tab!sf2.Form.RecordsetClone

Ducali_tab is the parent form
The on current event is for sf1 the other subform on Ducali_tab

Douglas J. Steele said:
So what happens if you remove the square brackets in your Set statement?

Set rst1 = forms!p!sf2.Form.RecordsetClone

Is that the actual code you're using? The lack of uppercase letters in
what
you're posting makes me suspect you're not copying the actual code you're
using into your posts.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RHC said:
btw this works
MsgBox Forms!P!sf2.Name

:

sf2 must be the name of the subform control on form p: that may or may
not
be the same as the name of the form being used as the subform.

If sf2 is the name of the control, then

Set rst1 = forms![p]![sf2].Form.RecordsetClone

should work.

What exactly is, or isn't, happening to lead you to say it doesn't
work?
Are
you getting an error? If so, what error is it?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


thanks for your help. sorry typo on my part I am using

set rst1 = forms![p]![sf2].recordsetclone

the question is why doesnt this work.

:

access 2000

I have a form with 2 subforms. They are on 2 different pages of a
tab
control. Lets call the parent [P] and the 2 subforms [sf1] and
[sf2]

I am trying resync sf2 on the on current of sf1 but I cant seem to
find
the
syntax to correctly set a recordset clone object. the following
doesnt
work.

Private Sub Form_Current() 'of sf1

Dim rst, rst1 As dao.Recordset

rst1 = forms![p]![sf2].recordsetclone
or
rst1 = forms![p]![sf2].form.recordsetclone

Help!
 
G

Guest

i get the error msg "You entered an expression that has an invalid reference
to the property Form/Report."

Im starting to suspect that you cant do it. Reference the .form properties
of one subform from another at the same level on the same parent form. It
doesnt work in Access 2003 either. Maybe its a bug in Access.

Douglas J. Steele said:
I would expect that to work. What's happening instead?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RHC said:
here is the exact code

Private Sub Form_Current()

Dim rst As dao.Recordset
Dim rst1 As dao.Recordset
Dim l As Long
Dim s As String

On Error GoTo eh

Set rst1 = Forms!Ducali_tab!sf2.Form.RecordsetClone

Ducali_tab is the parent form
The on current event is for sf1 the other subform on Ducali_tab

Douglas J. Steele said:
So what happens if you remove the square brackets in your Set statement?

Set rst1 = forms!p!sf2.Form.RecordsetClone

Is that the actual code you're using? The lack of uppercase letters in
what
you're posting makes me suspect you're not copying the actual code you're
using into your posts.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


btw this works
MsgBox Forms!P!sf2.Name

:

sf2 must be the name of the subform control on form p: that may or may
not
be the same as the name of the form being used as the subform.

If sf2 is the name of the control, then

Set rst1 = forms![p]![sf2].Form.RecordsetClone

should work.

What exactly is, or isn't, happening to lead you to say it doesn't
work?
Are
you getting an error? If so, what error is it?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


thanks for your help. sorry typo on my part I am using

set rst1 = forms![p]![sf2].recordsetclone

the question is why doesnt this work.

:

access 2000

I have a form with 2 subforms. They are on 2 different pages of a
tab
control. Lets call the parent [P] and the 2 subforms [sf1] and
[sf2]

I am trying resync sf2 on the on current of sf1 but I cant seem to
find
the
syntax to correctly set a recordset clone object. the following
doesnt
work.

Private Sub Form_Current() 'of sf1

Dim rst, rst1 As dao.Recordset

rst1 = forms![p]![sf2].recordsetclone
or
rst1 = forms![p]![sf2].form.recordsetclone

Help!
 
W

warrior

RHC said:
i get the error msg "You entered an expression that has an invalid reference
to the property Form/Report."

Im starting to suspect that you cant do it. Reference the .form properties
of one subform from another at the same level on the same parent form. It
doesnt work in Access 2003 either. Maybe its a bug in Access.

Douglas J. Steele said:
I would expect that to work. What's happening instead?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RHC said:
here is the exact code

Private Sub Form_Current()

Dim rst As dao.Recordset
Dim rst1 As dao.Recordset
Dim l As Long
Dim s As String

On Error GoTo eh

Set rst1 = Forms!Ducali_tab!sf2.Form.RecordsetClone

Ducali_tab is the parent form
The on current event is for sf1 the other subform on Ducali_tab

:

So what happens if you remove the square brackets in your Set statement?

Set rst1 = forms!p!sf2.Form.RecordsetClone

Is that the actual code you're using? The lack of uppercase letters in
what
you're posting makes me suspect you're not copying the actual code you're
using into your posts.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


btw this works
MsgBox Forms!P!sf2.Name

:

sf2 must be the name of the subform control on form p: that may or may
not
be the same as the name of the form being used as the subform.

If sf2 is the name of the control, then

Set rst1 = forms![p]![sf2].Form.RecordsetClone

should work.

What exactly is, or isn't, happening to lead you to say it doesn't
work?
Are
you getting an error? If so, what error is it?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


thanks for your help. sorry typo on my part I am using

set rst1 = forms![p]![sf2].recordsetclone

the question is why doesnt this work.

:

access 2000

I have a form with 2 subforms. They are on 2 different pages of a
tab
control. Lets call the parent [P] and the 2 subforms [sf1] and
[sf2]

I am trying resync sf2 on the on current of sf1 but I cant seem to
find
the
syntax to correctly set a recordset clone object. the following
doesnt
work.

Private Sub Form_Current() 'of sf1

Dim rst, rst1 As dao.Recordset

rst1 = forms![p]![sf2].recordsetclone
or
rst1 = forms![p]![sf2].form.recordsetclone

Help!
RHC
If I understand you, you are trying to reference the subform. If I am
correct, try this.To refer to a control on a subform, use the following syntax:

Forms![main form name]![subform control name].Form![control name]
 
G

Guest

thanks for the reply warrior but if you look through the thread you will see
that what i am trying to do is set a recordset variable to the
recordsetclone of one subform form the current() event of another subform.
Both subforms are at the same level on the parent. The syntax you describe
is basicly what I have been trying and it doesnt work.

warrior said:
i get the error msg "You entered an expression that has an invalid reference
to the property Form/Report."

Im starting to suspect that you cant do it. Reference the .form properties
of one subform from another at the same level on the same parent form. It
doesnt work in Access 2003 either. Maybe its a bug in Access.

Douglas J. Steele said:
I would expect that to work. What's happening instead?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


here is the exact code

Private Sub Form_Current()

Dim rst As dao.Recordset
Dim rst1 As dao.Recordset
Dim l As Long
Dim s As String

On Error GoTo eh

Set rst1 = Forms!Ducali_tab!sf2.Form.RecordsetClone

Ducali_tab is the parent form
The on current event is for sf1 the other subform on Ducali_tab

:

So what happens if you remove the square brackets in your Set statement?

Set rst1 = forms!p!sf2.Form.RecordsetClone

Is that the actual code you're using? The lack of uppercase letters in
what
you're posting makes me suspect you're not copying the actual code you're
using into your posts.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


btw this works
MsgBox Forms!P!sf2.Name

:

sf2 must be the name of the subform control on form p: that may or may
not
be the same as the name of the form being used as the subform.

If sf2 is the name of the control, then

Set rst1 = forms![p]![sf2].Form.RecordsetClone

should work.

What exactly is, or isn't, happening to lead you to say it doesn't
work?
Are
you getting an error? If so, what error is it?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


thanks for your help. sorry typo on my part I am using

set rst1 = forms![p]![sf2].recordsetclone

the question is why doesnt this work.

:

access 2000

I have a form with 2 subforms. They are on 2 different pages of a
tab
control. Lets call the parent [P] and the 2 subforms [sf1] and
[sf2]

I am trying resync sf2 on the on current of sf1 but I cant seem to
find
the
syntax to correctly set a recordset clone object. the following
doesnt
work.

Private Sub Form_Current() 'of sf1

Dim rst, rst1 As dao.Recordset

rst1 = forms![p]![sf2].recordsetclone
or
rst1 = forms![p]![sf2].form.recordsetclone

Help!
RHC
If I understand you, you are trying to reference the subform. If I am
correct, try this.To refer to a control on a subform, use the following syntax:

Forms![main form name]![subform control name].Form![control name]
 

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