Tabbing from sub form to main form

  • Thread starter Thread starter Steve G
  • Start date Start date
S

Steve G

Hi All

I am using this code to tab from the last text box in a sub form back to the
next text box in the main form:

Private Sub PatWtDate_Exit(Cancel As Integer)
On Error GoTo Error_Routine
Dim RS As Recordset
Set RS = Me.RecordsetClone
Me.Dirty = False
RS.MoveLast
If StrComp(Me.Bookmark, RS.Bookmark, 0) = 0 Then
Forms![frmReferral]![InsID].SetFocus
' The following line may be removed in version 2.0
' Forms![Orders]![Orders Subform].Requery
End If
Exit Sub
Error_Routine:
MsgBox "You must be on a record with data"
Exit Sub
End Sub

This works well for new records...however, when I try using it in a form to
edit an existing record, I am getting the error message shown above: "You
must be on a record with data". In this instance, data is already
present....I've tried several modifications, but can't seem to get it to
work right...

Any help would be much appreciated.

Steve G
 
You are getting you own error message text. You will get this for any number
of errors that might occur. Try replacing you error code with
msgbox error.number & " " & error.description

so you can see the *real* problem.
--

peter walker MVP

Please post replies to the news group so everyone can benefit.
www.papwalker.com
 
This is giving me a rutime error 424 "Object Required"

Steve G

peter walker said:
You are getting you own error message text. You will get this for any number
of errors that might occur. Try replacing you error code with
msgbox error.number & " " & error.description

so you can see the *real* problem.
--

peter walker MVP

Please post replies to the news group so everyone can benefit.
www.papwalker.com

Steve G said:
Hi All

I am using this code to tab from the last text box in a sub form back to the
next text box in the main form:

Private Sub PatWtDate_Exit(Cancel As Integer)
On Error GoTo Error_Routine
Dim RS As Recordset
Set RS = Me.RecordsetClone
Me.Dirty = False
RS.MoveLast
If StrComp(Me.Bookmark, RS.Bookmark, 0) = 0 Then
Forms![frmReferral]![InsID].SetFocus
' The following line may be removed in version 2.0
' Forms![Orders]![Orders Subform].Requery
End If
Exit Sub
Error_Routine:
MsgBox "You must be on a record with data"
Exit Sub
End Sub

This works well for new records...however, when I try using it in a form to
edit an existing record, I am getting the error message shown above: "You
must be on a record with data". In this instance, data is already
present....I've tried several modifications, but can't seem to get it to
work right...

Any help would be much appreciated.

Steve G
 
comment out the
on error ....
and see what line it fails on

I also have some concerns about the recordsetclone / bookmark surviving the
update or possibly the reference to the control.
BTY
You can use the
Me.Parent property
to refer to the 'main' form...
Me.Parent!InsID.SetFocus

--

peter walker MVP

Please post replies to the news group so everyone can benefit.
www.papwalker.com

Steve G said:
This is giving me a rutime error 424 "Object Required"

Steve G

peter walker said:
You are getting you own error message text. You will get this for any number
of errors that might occur. Try replacing you error code with
msgbox error.number & " " & error.description

so you can see the *real* problem.
--

peter walker MVP

Please post replies to the news group so everyone can benefit.
www.papwalker.com

Steve G said:
Hi All

I am using this code to tab from the last text box in a sub form back
to
the
next text box in the main form:

Private Sub PatWtDate_Exit(Cancel As Integer)
On Error GoTo Error_Routine
Dim RS As Recordset
Set RS = Me.RecordsetClone
Me.Dirty = False
RS.MoveLast
If StrComp(Me.Bookmark, RS.Bookmark, 0) = 0 Then
Forms![frmReferral]![InsID].SetFocus
' The following line may be removed in version 2.0
' Forms![Orders]![Orders Subform].Requery
End If
Exit Sub
Error_Routine:
MsgBox "You must be on a record with data"
Exit Sub
End Sub

This works well for new records...however, when I try using it in a
form
to
edit an existing record, I am getting the error message shown above: "You
must be on a record with data". In this instance, data is already
present....I've tried several modifications, but can't seem to get it to
work right...

Any help would be much appreciated.

Steve G
 
Thanks Peter...I'll give that a shot

Steve G

peter walker said:
comment out the
on error ....
and see what line it fails on

I also have some concerns about the recordsetclone / bookmark surviving the
update or possibly the reference to the control.
BTY
You can use the
Me.Parent property
to refer to the 'main' form...
Me.Parent!InsID.SetFocus

--

peter walker MVP

Please post replies to the news group so everyone can benefit.
www.papwalker.com

Steve G said:
This is giving me a rutime error 424 "Object Required"

Steve G
back
to
the
next text box in the main form:

Private Sub PatWtDate_Exit(Cancel As Integer)
On Error GoTo Error_Routine
Dim RS As Recordset
Set RS = Me.RecordsetClone
Me.Dirty = False
RS.MoveLast
If StrComp(Me.Bookmark, RS.Bookmark, 0) = 0 Then
Forms![frmReferral]![InsID].SetFocus
' The following line may be removed in version 2.0
' Forms![Orders]![Orders Subform].Requery
End If
Exit Sub
Error_Routine:
MsgBox "You must be on a record with data"
Exit Sub
End Sub

This works well for new records...however, when I try using it in a form
to
edit an existing record, I am getting the error message shown above: "You
must be on a record with data". In this instance, data is already
present....I've tried several modifications, but can't seem to get
it
 
Yep....that did the trick. Found the error and corrected it....

Thanks, Peter...dunno why I didn't think of that...

Steve G

peter walker said:
comment out the
on error ....
and see what line it fails on

I also have some concerns about the recordsetclone / bookmark surviving the
update or possibly the reference to the control.
BTY
You can use the
Me.Parent property
to refer to the 'main' form...
Me.Parent!InsID.SetFocus

--

peter walker MVP

Please post replies to the news group so everyone can benefit.
www.papwalker.com

Steve G said:
This is giving me a rutime error 424 "Object Required"

Steve G
back
to
the
next text box in the main form:

Private Sub PatWtDate_Exit(Cancel As Integer)
On Error GoTo Error_Routine
Dim RS As Recordset
Set RS = Me.RecordsetClone
Me.Dirty = False
RS.MoveLast
If StrComp(Me.Bookmark, RS.Bookmark, 0) = 0 Then
Forms![frmReferral]![InsID].SetFocus
' The following line may be removed in version 2.0
' Forms![Orders]![Orders Subform].Requery
End If
Exit Sub
Error_Routine:
MsgBox "You must be on a record with data"
Exit Sub
End Sub

This works well for new records...however, when I try using it in a form
to
edit an existing record, I am getting the error message shown above: "You
must be on a record with data". In this instance, data is already
present....I've tried several modifications, but can't seem to get
it
 
Back
Top