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

cycle through records to calculate 1

Status
Not open for further replies.

gr8whitewaldron

Technical User
Aug 6, 2003
25
0
0
US
Hello -
I have a database with a master table that contains almost all of the information I need. I want to write a piece of code that will start at the first record, make some calculations, save the value in one of the fields and move onto the next. The calculation and save I can handle, but I need to know how to set up the reference to my database so that I can select, say, record 1, 2, etc.

Pre-Thanks
 
Try this - it will process on record at a time until it reaches the end of the table

Function ProcessTableRecord()
Dim ThisDatabase As Database
Dim RcdSt As Recordset
Dim TableName As String
TableName = "YourTablesName"
Set ThisDatabase = CurrentDb
Set RcdSt = ThisDatabase.OpenRecordset(TableName, dbOpenDynaset)

RcdSt.MoveFirst
Do Until RcdSt.EOF
RcdSt.Edit
RcdSt.Fields(X) = RcdSt.Fields(Y) * RcdSt.Fields(Z)
RcdSt.Update
RcdSt.MoveNext
Loop

End Function

X,Y, and Z = the Ordinal(left to right) position of each files in the record being processed with 0(Zero) being the first field in the record

RGB
 
RGB -

I believe that gr8white wants record's - not fields


gr8white - you can use clones. See MS-Access help "Clone"

You could possibly also open multiple instances of the record.

Also - you can use bookmarks.
I would honestly suggest using clones and/or bookmarks. Look in MSA help for actually code. If you're still stuck after this, post and I'll take some time and point you further in the right direction. Mind you though - when I write things on the fly they never work perfectly, and I mostly only write things to give people a general direction. Since this is more of an advice forum and not a "do my work for me" forum.

Have fun,





Randall Vollen
National City Bank Corp.

Just because you have an answer - doesn't mean it's the best answer.
 
don't mind my post then :p lol - I read this wrong ;-)

Randall Vollen
National City Bank Corp.

Just because you have an answer - doesn't mean it's the best answer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top