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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Goto a certain Record quick

Status
Not open for further replies.

icupat

Technical User
Aug 6, 2002
25
CA
Is there an easy way to go to a certain record without going through all the previous records??

ie. If I had a 1000 records and I wanted to goto record 499 of 1000 then the only way I can see doing it is a for loop with 1 to 499 and using the "next form" command.... which would take quite a while to execute.

Is there a command like

docmd.gotorecord, 499

???
Of course the 499 will be a variable in reality, but I'm just tyring to get the right syntax for the job.

Thanks.
 
Not sure why you would want to go to a specific record number, but the syntax below should do it:

DoCmd.GoToRecord acDataTable, "tablename", acFirst

DoCmd.GoToRecord acDataTable, &quot;tablename&quot;, acGoTo, <recordnumber>

If you are working with a form instead of table, replace acDataTable with acDataForm dz
dzaccess@yahoo.com
 
hmm.. thought i had tried that, but perhaps i put too many commas.. thanks anyways.

 
hmm.. thought i had tried that, but perhaps i put too many commas.. thanks anyways.

I actually think there might be a better way to do what I wanted. But originally what I wanted was one form with an employees company info, then you click on a button and goto to a password-protected form with their salary info. So ideally when you add a new employee to the database, a new entry in the salary table AND employeeinfo table would be created. And if an employee is deleted from the database, both entries (from employeeinfo table AND salary table) are deleted.

I'm thinking this could be done through a relationship, but that would also require restarting the tables and re-entering each fields parameters, would it not? (so that the ID's correspond).....
 
The choice between relating tables or creating a flat file generally comes down to whether data would be repeated in a single table. If you need to enter more than one record about the same person, then their name would have to be repeated in a table. In this instance, it would be better to create related tables so each person's name is only in one record in the parent table. If you can get all the information about a person in one record, then there might not be any benefit to relating tables. I don't see why you couldn't include the person's salary in the employeeinfo table. Why do you want to store the salaries in a separate table? If you store the social security number, would you put that in a separate table too?

Back to your original issue, wouldn't it be better to search for a record by the person's name or ID? Why do you want to go to a specific record number? The record number isn't really relevant.

Best regards, dz
dzaccess@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top