Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Have form open to the last record.

Status
Not open for further replies.

wbg34

IS-IT--Management
Nov 2, 2000
550
US
How can I get a form to open and display the last record by default. I have a form that passes info to another form when you open that form. When the second form opens it displays the information that is from the first record in the table where the info is stored. You have to click on the last record button to be able to see the info that was just passed to the second form. I want the form to open and display the correct info.
 
Hi

I assume you are opening the second form via a command like

DoCmd.OpenForm ..etc

yes?

if you consider the full syntax

DoCmd.OpenForm formname[, view][, filtername][, wherecondition][, datamode][, windowmode][, openargs]

you can put something like

DoCmd.OPenForm "MyForm",,"MyKey = " & keyvalue

where MyForm is your form name, MyKey is the name of theunique key to identify the record (ie Prime key) and keyvalue is a variable containing that key, if the key is a numeric the syntax is as I have it, if it is a string you need to enclose the keyvalue in ' so

",,"MyKey = '" & keyvalue & "'"

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
or in the forms on open event you could put this line of code:
DoCmd.GoToRecord , , acLast
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top