Communauté Informatique NDFR.net : VBA sur access - Programmation (C/C++, Delphi, VB, etc.)
 
VBA sur access
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 15-11-2004, 16:24
sim140680's Avatar
sim140680 sim140680 is offline
Droopy style
 
Join Date: 16-11-2002
Age: 45
Posts: 278
Salut

Avec ce code tu peux exporter une table ACCESS en ficher EXCEL, c'est assez "bateau" mais ça marche bien (reste à vérifier, j'ai fait quelques modif à la volée):


Private Sub test_Click()
Dim db As Database
Dim qdf As QueryDef
Dim chSQL As String
Dim Name As String
Dim paramDate As Date

Name = "TEST"
Set db = CurrentDb
db.QueryDefs.Refresh


For Each qdf In db.QueryDefs
If qdf.Name = [Name] Then
db.QueryDefs.Delete qdf.[Name]
End If
Next qdf


chSQL = "SELECT [Requête].Champ1, [Requête].champ2, .... FROM [Requête] WHERE ..... ;"

Set qdf = db.CreateQueryDef([Name], chSQL)

If DCount("*", [Name]) > 0 Then

'On execute la Requête
DoCmd.OpenQuery [Name], acNormal, acEdit
'On exporte vers le fichier
DoCmd.OutputTo acOutputQuery, [Name], acFormatXLS, Path & NomFich & ".xls", False

Else
MsgBox "Il n'y a pas de donnée pour cette requête", vbInformation + vbOKOnly, "Information"
End If

End Sub
__________________
Il est plus facile de désintégrer un atome qu'un préjugé. Albert Einstein
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA pour ACCESS un simple SELECT en SQL Ichtus Programmation (C/C++, Delphi, VB, etc.) 4 30-07-2004 19:25
Mise à jour critique pour Microsoft Data Access Components Cougar Actualité 1 02-07-2004 22:23
celineee se met au VBA (pour access) celineee Programmation (C/C++, Delphi, VB, etc.) 4 29-04-2004 21:47
migration mysql -> access ok1234 Programmation Web (HTML, PHP, ASP, Java, XML, etc.) 6 01-04-2004 20:54
Microsoft Data Access Components (MDAC) 2.71 Service Pack 1 Werner Actualité 1 02-07-2003 11:48

All times are GMT +2. The time now is 09:42.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.