LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default database query to upload a dbf file


Hello

you may try the macro to join the .dbf bases


Sub piloterDBase_jointureBases()
'activate Microsoft ActiveX Data Objects x.x Library
Dim Cn As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim Chemin As String, Cible As String

'the dbf bases are supposed in the same directory
'C:\Documents and Settings\michel\dossier\Base1.dbf
'C:\Documents and Settings\michel\dossier\Base2.dbf
Chemin = "C:\Documents and Settings\michel\dossier"

Set Cn = New ADODB.Connection
Cn.Open _
"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" & _
Chemin & ";"

'Base1= first file name(.dbf) has the following fields
CLIENT_ID,CLIENT_NAME
'Base2=Next file name(.dbf) has following fields
CLIENT_ID,BILL_DATE,BILL_AMOUNT
Cible = "SELECT Base1.CLIENT_NAME , Base2.BILL_DATE , Base2.BILL_AMOUNT
" & _
" FROM Base1 INNER JOIN Base2 ON Base1.CLIENT_ID=Base2.CLIENT_ID"

Set Rs = New ADODB.Recordset

With Rs
..ActiveConnection = Cn
..Open Cible, , adOpenStatic, adLockOptimistic, adCmdText
End With

If Rs.EOF Then
MsgBox "no records"
Rs.Close
Cn.Close
Exit Sub
End If

Range("A1").CopyFromRecordset Rs
Rs.Close
Cn.Close
End Sub



Regards ,
michel


--
michelxld
------------------------------------------------------------------------
michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367
View this thread: http://www.excelforum.com/showthread...hreadid=470454

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Build a query from a web-based database or a PDF file. Damian Excel Discussion (Misc queries) 0 October 26th 09 01:53 PM
database query not showing foxpro database How I import data mangat New Users to Excel 1 June 24th 07 03:31 PM
upload file name choice[_2_] Excel Programming 3 March 25th 05 10:38 PM
how-to use Excel to upload records to a MySQL database? chris Excel Programming 3 November 15th 04 01:43 PM
Upload Excel data into online database DH[_3_] Excel Programming 1 September 30th 03 12:57 AM


All times are GMT +1. The time now is 04:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"