1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Sub fonctionTest
Dim dbs, DbFullName, acc, rs
Set acc = createobject("Access.Application")
DbFullName = "D:\EDF_vb\BDD_test.accdb"
Set dbs = acc.DBEngine.OpenDatabase(DbFullName, False, False)
Set rs = dbs.Execute ("SELECT Ville FROM TableTest")
'While loop, loops through all available results
DO WHILE NOT rs.EOF
'add names seperated by comma to getNames
getNames = getNames + rs.Fields(0) & ","
'move to next result before looping again
'this is important
rs.MoveNext
'continue loop
Loop
dbs.Close
End Sub |