help with vb and access

  • Thread starter Thread starter news
  • Start date Start date
N

news

Hi all perhaps someone could help me run before I can crawl
I have a data a database of clients
and from a separate vb program (which does other things) I wish to open my
clients database, select surname field from clients table order by surname,
remove repeats and export to a text file surnames.txt

this is as far as I have got
temp1 = "SELECT surname FROM clients"
Set dbs = OpenDatabase("C:\clients.mdb")
dbs.Execute temp1
dbs.Close
vb5 comes with an error cannot execute select query
and yet in another program with similar code INSERT works fine
any help appreciated and thanks in advance
 
Hi,

Re. VB5 Error Msg: - You can only execute action queries (e.g. Select Into,
Insert, Delete, Drop, Alter...), not select queries. See online help for
more.

Re. VB5 SQL: - To meet your objective, you need to use "Select Distinct
Surname From Clients Order By Surname" to remove duplicates and properly
sort.

Re. VB5 Exporting To Text: - You might want to consider Automation back to
Access to execute the TransferText or TransferDatabase action. See "Tip #9b"
on my site for an example, if needed.
 
Back
Top