Results 1 to 9 of 9

Thread: [RESOLVED] Data Extraction

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    32

    Resolved [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.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Data Extraction

    Welcome to the forums.
    You should edit that post to remove your email address. The forums are scanned by bots, and your address will be open to spammers in a matter of hours. Include it in your profile, so only members can see it. Or at the very least use AT instead of the @ symbol so that the bots don't recognize it.

    I have this sample that does exactly what you want. No charge!
    (I wouldn't know who to split it with )
    Attached Files Attached Files

  5. #5
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    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

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    32

    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

  7. #7
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    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:
    1. Option Explicit
    2.  
    3. 'Reference: M$ ActiveX Data Objects 2.X Library
    4.  
    5. Private Sub Form_Load()
    6. Dim strSQL As String
    7. Dim rst As ADODB.Recordset
    8. Dim cnn As ADODB.Connection
    9.  
    10. On Error GoTo Err_Handler
    11.  
    12.     Set rst = New ADODB.Recordset
    13.     Set cnn = New ADODB.Connection
    14.  
    15.     strSQL = "SELECT * FROM [tblCustomers]"
    16.  
    17.     cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Customers.mdb;Persist Security Info=False;"
    18.  
    19.     rst.CursorLocation = adUseClient 'Set to enable Cursor movement
    20.     rst.Open strSQL, cnn, adOpenForwardOnly, adLockOptimistic
    21.  
    22.     'Check RS for data
    23.     If Not rst.BOF And Not rst.EOF Then
    24.  
    25.         MsgBox rst.GetString '<<<<< Do your Excel stuff here!!!!!!!!!!
    26.  
    27.     End If
    28.  
    29.     rst.Close
    30.     cnn.Close
    31.  
    32.     Set rst = Nothing
    33.     Set cnn = Nothing
    34.  
    35. Exit Sub
    36.  
    37. Err_Handler:
    38.  
    39.     If Not (rst Is Nothing) Then
    40.         If rst.State = adStateOpen Then
    41.             rst.Close
    42.             Set rst = Nothing
    43.         End If
    44.     End If
    45.  
    46.     If Not (cnn Is Nothing) Then
    47.         If cnn.State = adStateOpen Then
    48.             cnn.Close
    49.             Set cnn = Nothing
    50.         End If
    51.     End If
    52.  
    53.     MsgBox "Description: " & Err.Description & vbCrLf & _
    54.         "Number: " & Err.Number, vbOKOnly + vbInformation, "Error"
    55. End Sub
    Last edited by Bruce Fox; Sep 11th, 2005 at 08:09 PM.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  9. #9

    Thread Starter
    Member
    Join Date
    Sep 2005
    Posts
    32

    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
  •  



Click Here to Expand Forum to Full Width