Selasa, 25 Oktober 2011

[MS_AccessPros] My first Do Loop but with questions

 

Hello all,

I am practicing my first do loop and questioning why it took me so long to learn this. But here I am with a question.

I have the below code that I am trying to just get a message box to show first, last and address in the msgbox. If I use the first msgbox in the code it works great. The email addresses show up in the msgbox and all is great. But when I try to use the second msgbox in the code, I get the first name from the Contacts table and the email addresses from the tblTodaysBirthdays table cycle through with the same name. But the person's name in the msgbox is from the main table not the table the select statement is based on.

I have several tables involved in the question. The contacts table and the tblTodaysBirthdays. The latter is a table made from a make table query built every day based on the Contacts table.

Private Sub Command281_Click()
Dim mydb As DAO.Database
Dim myset As DAO.Recordset
Dim MyAddress As String

Set mydb = CurrentDb
Set myset = mydb.OpenRecordset("SELECT * FROM tblTodaysBirthdays where [E-mail Address] is not null")

Do Until myset.EOF

MyAddress = myset![E-mail Address]
'MsgBox "My name and address" & " " & MyAddress
MsgBox "My name and address is" & " " & [First Name] & " " & [Last Name] & " " & MyAddress
myset.MoveNext

Loop
End Sub

What am I missing here?

Thanks for the help

Jim Wagner

__._,_.___
Recent Activity:
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar