2013-06-09 3 views
0

안녕하세요 저는 VB와 Access의 초보자입니다. While 문을 꺼내고 버그를 생성 할 때마다 실행되지 않을지 궁금합니다. while 문은 MyList = MyRec [email]로 설정한다고 생각합니까?Visual Basic 쿼리의 값

하지만 왜 내가 While 문을 MyList = MyRec [email]로 바꿀 때마다 컴파일되지 않습니다. ...

Dim MyDB As DAO.Database, MyRec As DAO.Recordset, MyList As String 
Set MyDB = CurrentDb 
Set MyRec = MyDB.OpenRecordset("Select email From TableName") 
While Not MyRec.EOF ' Loop trough the table 
MyList = MyList & ";" & MyRec![email] 
MyRec.MoveNext 
Wend 
MyList = Mid(MyList, 2) 

' use you code here with the mail list ceated 

MyRec.Close 
MyDB.Close 

큰 감사를

나는 myList에 = MyRec [메일]로 myList에 에서 SQL 문을 배치 어디에 코드를 단순화하기 위해 노력하고있어,하지만 난 방법을 몰라!

답변

0

while은 실제로 SELECT 문으로 레코드 집합에 반환 된 모든 항목을 반복합니다. While 루프 .MoveNext에 대한 호출없이

While Not MyRec.EOF     ' While there are emails still in the recordset 
MyList = MyList & ";" & MyRec![email] ' Append the current email to the list 
MyRec.MoveNext      ' Get the next email in the list 
Wend 

, 당신은 목록에서 이메일 주소를 모두 검색 할 수 없습니다.

의미가 있습니까?

+0

아하 그렇습니다. MyRec! [email]합니까? – nomad