A Subroutine on record fields?

Mod

DoCmd.PostForHelp
Local time
Yesterday, 20:54
Joined
May 4, 2004
Messages
70
I'm pretty new to Access, but it seems to me there should be a way to do something like this:
Code:
Dim rec As Record
Dim tbl As Table

Set tbl = Access.GetTable ("Tablename")

Foreach rec In tbl
begin
if (!spellcheck(rec.TextField)) add_to_output(rec)
end

Obviously this isn't anywhere near to correct, but it should illustrate my goal. Essentially i want to run a function on a field of each record, for error checking, store and report the results.

Any advice is much appreciated!

P.S
I didn't do any lurking before posting here, so please be gentle if I am in the wrong forum or have broken any other rule, thanks.
 
Mod,

Code:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("YourTable")
While Not rst.EOF and Not rst.BOF
   rst.Edit
   rst!SomeField = SomeFunction(rs!SomeField)
   rst.Update
   rst.MoveNext
   Wend

You can also call a function from a query, if desired.

Also, see the FAQs, Code Sample and Sample Databases forums here.

Wayne
 
Thanks for your quick and informative response. That was exactly what I was looking for, and I appreciate it very much.
 

Users who are viewing this thread

Back
Top Bottom