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

Refering to certain record in Access

Status
Not open for further replies.

TTThio

Programmer
May 3, 2001
185
US
Hi folks,

is there a way to refer to certain record without using the bookmark property.

For instance,
if in Excel, by using rowindex, we can go into that cell record directly.
Exp: rowindex = 1
rst.movefirst
.cells(rowindex,1) = rst("A")
rst.movenext
rowindex = rowindex + 1

This way, along with recordset record movenext, the row is moving a step.

In Access, so far I just know a way to do this using bookmark property.
Exp. rst.movefirst
frm.bookmark = rst.bookmark
frm.fieldA = rst("A")
rst.movenext

But this way will work only if we want to fill up a form records one by one in order.

How if we want to say,
frm.fieldA record no.3 = rst("A") first record

In excel we can say .cells(rowindex+2,1) = rst("A") first record

How to refer to the frm/rpt certain record? Is there a better way?

Thanks ahead for the attention, I greatly appreciate any help.

Tin Tin



 
Access is not Excel. The way to refer to a record in access is by it's key or index. Each record is assigned a unique identifer. For example employee idnumber is what would identify an employee. It can either be something you assign when the record is added or an autonumber field generated automatically. Each field is given a name and each table as well. One way we retreive data then would be
Select StrEMPname from EmployeeTBL where employeeid = 123;
To fill a form or report in access just set the forms recordsource to the table name and the controls on the from to field names.
A form can be viewed in either a single record (form view), a continious form or in datasheet view. Another way to populate a form is to set the recordsource either using SQL,DAO or ADO. Either of these methods are highly versitile and allow the programmer flexibility.
Hopefully that answers some of your questions. Access help is very informative and comes with sample DB's to give you a go ahead.
 
Thanks gol4.

However, what I really don't understand the way to do things is for exp. I've already queried the record source by certain criteria. Now, the return results contain only 5 records which ID are 3,4,6,9,11. I need to perform a calculation based on the each record data.
So, in my logic, I can do some actions by refering to each record, for exp. go to result first record, calculate its fieldA, then go to next record, based on the first record fieldA, calculate 2nd record fieldA, etc....

I can refer to these records by using the bookmark property, but I wonder if there's another way to do this.

How if I don't want to do that kind of action in the form, but just in the report as basically I just need to show the results without letting the user see the calculation in the fly? Report doesn't have bookmark property.

This question is actually the basis of why I wonder if there's a way to go to a certain record position.






 
The problem with going to a certain record position is that sometimes you may have deleted out one somewhere, and now the absolute record position differs from the indexed field number. I'm not sure your circumstances but you can...

DoCmd.GoToRecord , &quot;tblName&quot;, acGoTo, <absolute record position>

Just when you start having problems with it going to the wrong record by a few realize what I said before. If your table is ever going to have records deleted out of it, this command will become useless to you.

As for the only other way to go to records is using DAO and ADO and I for one stink at using them so I won't give you any examples. Which reminds me, anyone know any good books on ADO or DAO?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top