reference to a form in subform

G

Guest

Hi,
I have a continuous subform with a Custom Navigation buttons form. The
navigation buttons work when I test the subform by itself but I can't make
them work when inside the Parent form. I get a message saying the subform is
not open.
Any help will be greatly appreciated!

Private Sub cmdFirst_Click()
On Error GoTo Err_cmdFirst_Click

DoCmd.GoToRecord acDataForm, Me.Parent.Name, acFirst

Exit_cmdFirst_Click:
Exit Sub

Err_cmdFirst_Click:
MsgBox Err.Description
Resume Exit_cmdFirst_Click

End Sub
 
G

Guest

Not sure if you are trying to move to the first record in the sub form, try

DoCmd.GoToRecord , , acFirst
 
G

Graham Mandeno

Hi gaba

Do you mean that the navigation buttons are on a subform of the subform?

If so, then the problem is that subforms don't exist as form's in their own
right, which is why Access thinks the form is not open.

Try this instead of the DoCmd.GoToRecord:

Me.Parent.Recordset.MoveFirst

If you are using an older version of Access (2000 or older I think) you will
need:

With Me.Parent
.RecordsetClone.MoveFirst
.Bookmark = .RecordsetClone.Bookmark
End With
 
G

Guest

Ofer,
Thanks for your quick response. I've tried your suggestion and is not doing
anything. Then I've removed the "Me.Parent.Name" part and got a message: This
action requires and objectName argument.
It seems I'm missing one the forms...
Main form: Jobs
Subform: Samples
Subform inside subform: NavButtons

I have buttons for First Record, Previous, Next, Last and New. It is driving
me crazy that it works alone but not when I open the main subform.

Thanks
Gaba
 
G

Guest

Thanks Graham. It works great.
If you don't mind helping me a little bit more...
How can I change this using the Recordset?
Thanks in advance
Gaba

Private Sub txtPos_AfterUpdate()
' Allow user to manually input current row number.
DoCmd.GoToRecord acDataForm, Me.Parent.Recordset, acGoTo,
Nz(Me.txtPos.Value, 0)

' SetFocus off of this control.
Me.txtHidden.SetFocus
End Sub


--
gaba :)


Graham Mandeno said:
Hi gaba

Do you mean that the navigation buttons are on a subform of the subform?

If so, then the problem is that subforms don't exist as form's in their own
right, which is why Access thinks the form is not open.

Try this instead of the DoCmd.GoToRecord:

Me.Parent.Recordset.MoveFirst

If you are using an older version of Access (2000 or older I think) you will
need:

With Me.Parent
.RecordsetClone.MoveFirst
.Bookmark = .RecordsetClone.Bookmark
End With

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

gaba said:
Hi,
I have a continuous subform with a Custom Navigation buttons form. The
navigation buttons work when I test the subform by itself but I can't make
them work when inside the Parent form. I get a message saying the subform
is
not open.
Any help will be greatly appreciated!

Private Sub cmdFirst_Click()
On Error GoTo Err_cmdFirst_Click

DoCmd.GoToRecord acDataForm, Me.Parent.Name, acFirst

Exit_cmdFirst_Click:
Exit Sub

Err_cmdFirst_Click:
MsgBox Err.Description
Resume Exit_cmdFirst_Click

End Sub
 
G

Graham Mandeno

Hi gaba

Try this:
Me.Parent.Recordset.AbsolutePosition = Nz(Me.txtPos.Value, 0) +1

Other recordset methods you might find useful are:
.MoveLast
.MoveNext
.MovePrevious
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

gaba said:
Thanks Graham. It works great.
If you don't mind helping me a little bit more...
How can I change this using the Recordset?
Thanks in advance
Gaba

Private Sub txtPos_AfterUpdate()
' Allow user to manually input current row number.
DoCmd.GoToRecord acDataForm, Me.Parent.Recordset, acGoTo,
Nz(Me.txtPos.Value, 0)

' SetFocus off of this control.
Me.txtHidden.SetFocus
End Sub


--
gaba :)


Graham Mandeno said:
Hi gaba

Do you mean that the navigation buttons are on a subform of the subform?

If so, then the problem is that subforms don't exist as form's in their
own
right, which is why Access thinks the form is not open.

Try this instead of the DoCmd.GoToRecord:

Me.Parent.Recordset.MoveFirst

If you are using an older version of Access (2000 or older I think) you
will
need:

With Me.Parent
.RecordsetClone.MoveFirst
.Bookmark = .RecordsetClone.Bookmark
End With

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

gaba said:
Hi,
I have a continuous subform with a Custom Navigation buttons form. The
navigation buttons work when I test the subform by itself but I can't
make
them work when inside the Parent form. I get a message saying the
subform
is
not open.
Any help will be greatly appreciated!

Private Sub cmdFirst_Click()
On Error GoTo Err_cmdFirst_Click

DoCmd.GoToRecord acDataForm, Me.Parent.Name, acFirst

Exit_cmdFirst_Click:
Exit Sub

Err_cmdFirst_Click:
MsgBox Err.Description
Resume Exit_cmdFirst_Click

End Sub
 
G

Guest

Graham,
Many thanks for such a great lesson today!
I took the +1, it was adding a record:

Me.Parent.Recordset.AbsolutePosition = Nz(Me.txtPos.Value, 0)

and it works wonderfully.

Again, thanks for your time and for sharing your knowledge.
--
gaba :)


Graham Mandeno said:
Hi gaba

Try this:
Me.Parent.Recordset.AbsolutePosition = Nz(Me.txtPos.Value, 0) +1

Other recordset methods you might find useful are:
.MoveLast
.MoveNext
.MovePrevious
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

gaba said:
Thanks Graham. It works great.
If you don't mind helping me a little bit more...
How can I change this using the Recordset?
Thanks in advance
Gaba

Private Sub txtPos_AfterUpdate()
' Allow user to manually input current row number.
DoCmd.GoToRecord acDataForm, Me.Parent.Recordset, acGoTo,
Nz(Me.txtPos.Value, 0)

' SetFocus off of this control.
Me.txtHidden.SetFocus
End Sub


--
gaba :)


Graham Mandeno said:
Hi gaba

Do you mean that the navigation buttons are on a subform of the subform?

If so, then the problem is that subforms don't exist as form's in their
own
right, which is why Access thinks the form is not open.

Try this instead of the DoCmd.GoToRecord:

Me.Parent.Recordset.MoveFirst

If you are using an older version of Access (2000 or older I think) you
will
need:

With Me.Parent
.RecordsetClone.MoveFirst
.Bookmark = .RecordsetClone.Bookmark
End With

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Hi,
I have a continuous subform with a Custom Navigation buttons form. The
navigation buttons work when I test the subform by itself but I can't
make
them work when inside the Parent form. I get a message saying the
subform
is
not open.
Any help will be greatly appreciated!

Private Sub cmdFirst_Click()
On Error GoTo Err_cmdFirst_Click

DoCmd.GoToRecord acDataForm, Me.Parent.Name, acFirst

Exit_cmdFirst_Click:
Exit Sub

Err_cmdFirst_Click:
MsgBox Err.Description
Resume Exit_cmdFirst_Click

End Sub
 

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