|
-
Sep 11th, 2005, 07:55 PM
#1
Thread Starter
Member
[RESOLVED] Data Extraction
Hi all,
Does anyone have any info on how to extract data from Access using VB and then creating an excel file containing those data? Any recommended book/sites? I'm willing to pay for any sample code/program. My email [email]
thanks
Daniel
Last edited by Daniel_Cooper; Sep 11th, 2005 at 08:04 PM.
-
Sep 11th, 2005, 07:57 PM
#2
Re: Data Extraction
Welcome to the Forums.
You shouldnt post your email as you will get spammed. Members can contact you via replying to this post or via email, if you specified the option in your control panel. 
Moved from Classic VB.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 11th, 2005, 08:00 PM
#3
Re: Data Extraction
What version of Access and Excel are you running? Do you have any code written yet?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 11th, 2005, 08:01 PM
#4
-
Sep 11th, 2005, 08:01 PM
#5
Re: Data Extraction
Hi Daniel, Welcome.
Here is an example from M$: http://support.microsoft.com/default...NoWebContent=1
There are also plenty of other examples posted on this Forum, just do a Search
-
Sep 11th, 2005, 08:03 PM
#6
Thread Starter
Member
Re: Data Extraction
i'm running access & excel 2003. i've not started anything, i need a guide to follow. i'm just following Vb from scratch. you have any suggestions?
thanks
-
Sep 11th, 2005, 08:06 PM
#7
Re: Data Extraction
As an Alternate..
Here is the Access part (need to add the Excel load routine):
Note: Change the .MDB file to suit your needs.
VB Code:
Option Explicit
'Reference: M$ ActiveX Data Objects 2.X Library
Private Sub Form_Load()
Dim strSQL As String
Dim rst As ADODB.Recordset
Dim cnn As ADODB.Connection
On Error GoTo Err_Handler
Set rst = New ADODB.Recordset
Set cnn = New ADODB.Connection
strSQL = "SELECT * FROM [tblCustomers]"
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Customers.mdb;Persist Security Info=False;"
rst.CursorLocation = adUseClient 'Set to enable Cursor movement
rst.Open strSQL, cnn, adOpenForwardOnly, adLockOptimistic
'Check RS for data
If Not rst.BOF And Not rst.EOF Then
MsgBox rst.GetString '<<<<< Do your Excel stuff here!!!!!!!!!!
End If
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
Exit Sub
Err_Handler:
If Not (rst Is Nothing) Then
If rst.State = adStateOpen Then
rst.Close
Set rst = Nothing
End If
End If
If Not (cnn Is Nothing) Then
If cnn.State = adStateOpen Then
cnn.Close
Set cnn = Nothing
End If
End If
MsgBox "Description: " & Err.Description & vbCrLf & _
"Number: " & Err.Number, vbOKOnly + vbInformation, "Error"
End Sub
Last edited by Bruce Fox; Sep 11th, 2005 at 08:09 PM.
-
Sep 11th, 2005, 08:07 PM
#8
Re: Data Extraction
Yes, Bruce's MS link is a clean simple example. There is still another way using only Access and Excel but since you want to use VB6 too, go with the link in post #5.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 11th, 2005, 08:13 PM
#9
Thread Starter
Member
Re: Data Extraction
Thanks a lot for all the help peeps!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|