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

for each value in a field in a table 1

Status
Not open for further replies.

hovercraft

Technical User
Jun 19, 2006
236
US
Greetings,

How could I cycle through each value of a field in a table and use that value in a function?

something to the effect of:
global var_myvar as string
var_myvar = for each fieldname in tablename
call functionname
next var_myvar

and then in functionname I would use var_myvar for something.
I hope this makes sense. That is to say, I hope I've explained myself.

Thanks for any assistance,
Hovercraft

 
Have a look at Recordset

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Well, your logic, I believe, would ultimately result
in the value, of the last record. One Value.

How can you have a field/control/variable, equal a function
that the value changes 100x per call?

Now maybe you're thinking a block of values?
Like PHV said, a recordset, ...maybe using GetString()?
 
Try PHV's suggestion of a recordset (including the cautions that Zion7 suggests.)

Another tactic may be to write SQL that invokes the function and places the result in a computed field in the query.
 
How are ya hovercraft . . .

Example:
Code:
[blue]   Dim db As DAO.Database, rst As DAO.Recordset, Rtn
   
   Set db = CurrentDb
   Set rst = db.OpenRecordset([purple][b][i]TableName[/i][/b][/purple], dbOpenDynaset)
   
   If rst.EOF Then
      MsgBox "Table is Empty! . . . No records!"
   Else
      Do
         Rtn = [purple][b][i]FunctionName[/i][/b][/purple](rst![purple][b][i]FieldName[/i][/b][/purple])
         rst.MoveNext
      Loop Until rst.EOF
   End If
   
   Set rst = Nothing
   Set db = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks everyone. I'm sorry it's taken so long to get back to you. I've just spent the past 30+hours at work in one of those "database/sys admin" emergencies. I haven't slept and now I'm going to crash...

I'll review your suggestions when/if I wake up.

Thanks again,
Hovercraft
 
This is exactly what I was looking for. I knew of using Recordset however, I just wasn't sure how to get the value to a function. Now each value can be used in a query.
Thanks a ton!

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top