Ensuring correct record is always seen!

B

bubbles

I have a form with a command button that takes me to a report. In a previous
question I asked how to ensue that the record I was viewing on the form was
the one whose information was shown in the report. This has now been
achieved thanks to contributers replies by using the following code.

Private Sub cmd210Print_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[of ref] = """ & Me.[OF REF] & """"
DoCmd.Close

DoCmd.OpenReport "210 LETR - Showing Interest", acViewPreview, ,
strWhere
End If
End Sub

I now have the reverse problem. I want to ensure that I return to the same
form as I left and to the same record and preferably the same field. In
otherwords after viewing and printing the form I need to return to the same
spot in the form. Is this possible?
 
L

Larry Linson

The simplest way to accomplish what you want is to not close the form...
eliminate the DoCmd.Close from your code. If your form is a popup or modal,
the report will appear behind it, so you may need to convert it to a
"normal" form view.

Larry Linson
Microsoft Access MVP
 
B

bubbles

OK I've taken the DoCmd .Close out of the form.

I've checked that the Forms pop-up property is No and Modal is set to No.

I've ensured that there is no code active on closure of the report.

I do now do go back to the record in the form that I require BUT the form is
truncated - the top is chopped off. Why?

One thing I haven't done is convert the form to "normal" view - how do I do
that?

Pete

--
Peter J Aldersley (aka bubbles)
BEDWORTH
England


Larry Linson said:
The simplest way to accomplish what you want is to not close the form...
eliminate the DoCmd.Close from your code. If your form is a popup or modal,
the report will appear behind it, so you may need to convert it to a
"normal" form view.

Larry Linson
Microsoft Access MVP


bubbles said:
I have a form with a command button that takes me to a report. In a
previous
question I asked how to ensue that the record I was viewing on the form
was
the one whose information was shown in the report. This has now been
achieved thanks to contributers replies by using the following code.

Private Sub cmd210Print_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[of ref] = """ & Me.[OF REF] & """"
DoCmd.Close

DoCmd.OpenReport "210 LETR - Showing Interest", acViewPreview, ,
strWhere
End If
End Sub

I now have the reverse problem. I want to ensure that I return to the
same
form as I left and to the same record and preferably the same field. In
otherwords after viewing and printing the form I need to return to the
same
spot in the form. Is this possible?
 
Top