Go to Record....

  • Thread starter Thread starter qpurser
  • Start date Start date
Q

qpurser

Hi,
I have a mainform "orders" and a subform "orders by cust."
First I select on the mainform the name of a cust....In the subform I
get all the orders the cust. did.
Now I have a button on the mainform "Invoice preview".
How can I make it possible that I preview the last record from the
subform automatically.
For now I always had to move the cursor to the last record, otherwise
I would always get a preview from the first record in the subform...
THX for any help
Mike
 
Hi,

You would have to select (or move) to the last record on the subForm.

Here's what you could try behind your command button:

- say the name of the subForm Control is "mysubFormControl"
IMPORTANT: not concerned about the name of the Sub Form

- In the Visual Basic Editor window select the menu option Tools >
References and make sure "Microsoft DAO 3.6 Object Library" is checked.

- Sample code
Private Sub Commandbutton3_Click()
' declare a recordset object
Dim rst As DAO.Recordset

' make the recordset object equal to the RecordsetClone
of the
' subForm control
Set rst = Me.mysubFormControl.Form.RecordsetClone

' for the recordset move to the last record
rst.MoveLast

' open Report with where clause that compares against the
recordset object
DoCmd.OpenReport "Report1", acViewPreview, ,
"[ProductID]=" & rst!ProductID

' destroy the Recordset object
Set rst = Nothing

End Sub


I hope this helps! If you have additional questions on this topic, please
respond back to this posting.

Regards,

Eric Butts
Microsoft Access Support
 
Thx Eric,
It works.....
The only thing I had to do was instead of
Set rst = Me.mysubFormControl.Form.RecordsetClone
I had to change it to:
Set rst = Me.[mysubformControl].Form.RecordsetClone

Onec again...many thnks
 
Back
Top