Re: Lost in For Each loop
From: shaggles (anonymous_at_discussions.microsoft.com)
Date: 07/09/04
- Next message: Rick Brandt: "Re: How can i check for the current record status in access2000"
- Previous message: Matthew DeAngelis: "Re: Mail Merge Transaction"
- In reply to: Paul Johnson: "Re: Lost in For Each loop"
- Next in thread: Paul Johnson: "Re: Lost in For Each loop"
- Reply: Paul Johnson: "Re: Lost in For Each loop"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 9 Jul 2004 08:49:07 -0700
I get an error message say database is not a defined
datatype when I type "Dim db as Database".
>-----Original Message-----
>The For Each loop has to reference a logical element of a
collection. It
>usually works well to loop through fields in a recordset,
or elements in an
>array, or maybe the tables in a database's TableDefs
collection. I think
>what you want to do is walk through a recordset and
return all the
>Notice_Num values:
>
>Dim db As Database
>Set db = CurrentDb
>
>Dim rst As Recordset
>Set rst = db.OpenRecordset("MyTable")
>
>While Not rst.EOF
>
>' Your code here. You will access
>' table values using rst!Notice_Num
>
> rst.MoveNext
>Wend
>
>This will loop through every record in the table. If you
want to limit the
>scope, set a Where Condition thus:
>
>Set rst = db.OpenRecordset("SELECT * FROM MyTable WHERE
[SomeField] = '" &
>SomeTextValue & "'")
>
>HTH
>Paul Johnson
>
>"shaggles" <anonymous@discussions.microsoft.com> wrote in
message
>news:28b7a01c4651f$6676f4c0$a601280a@phx.gbl...
>> I have a database that tracks notices sent by various
>> regulatory organizations. The main form shows the
notice
>> information with a subform data*** listing the
impacted
>> departments. The users want to be able to click a
button
>> on the form and have an email go to each of the
>> departments on the subform. It seems like a for each
loop
>> is the right thing to use but I don't know how to
>> reference the notice number or the email address. I
tried:
>>
>> For Each Me!Notice_Num In tblNotices
>>
>> but that didn't even come close to working. I keep
>> getting an error message Type Mismatch. Can anyone
help?
>
>
>.
>
- Next message: Rick Brandt: "Re: How can i check for the current record status in access2000"
- Previous message: Matthew DeAngelis: "Re: Mail Merge Transaction"
- In reply to: Paul Johnson: "Re: Lost in For Each loop"
- Next in thread: Paul Johnson: "Re: Lost in For Each loop"
- Reply: Paul Johnson: "Re: Lost in For Each loop"
- Messages sorted by: [ date ] [ thread ]