Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-18-2011, 04:57 PM
Joe Patrick Joe Patrick is offline How to link a combobox to an access database? Windows 7 64bit How to link a combobox to an access database? Office 2007
Advanced Beginner
How to link a combobox to an access database?
 
Join Date: May 2011
Posts: 33
Joe Patrick is on a distinguished road
Default How to link a combobox to an access database?

Hi,

Can anyone help me with this?

I found this code but can't seem to get it to work.

Access file = PE_CG_list
Table = PE-GC-list


Column = PEs

I have the data source ending in .accdb because that's the path to the file although the original code said to put .mdb. When I put .mdb it says it can't find the file but with .accdb it says it doesn't know the database type.

I have references set to both ADO and Access.

Code:
Sub AutoOpen()
    On Error GoTo Document_Open_Err
    Dim cnn As New ADODB.Connection
    Dim rst As New ADODB.Recordset
    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=U:\TPCentral_Too\PE_GC_list.accdb"
.Open "SELECT [PEs] FROM PE-GC-list ORDER BY [PEs];", _
             cnn, adOpenStatic
    rst.MoveFirst
    With ThisDocument.ComboBox1
        .Clear
        Do
            .Add rst![PEs]
            rst.MoveNext
        Loop Until rst.EOF
    End With
Document_Open_Exit:
    On Error Resume Next
    rst.Close
    cnn.Close
    Set rst = Nothing
    Set cnn = Nothing
    Exit Sub
Document_Open_Err:
    MsgBox Err.Number & vbCrLf & Err.Description, vbCritical, "Error!"
    Resume Document_Open_Exit
End Sub
Any help is appreciated - thank you!
Reply With Quote
  #2  
Old 10-21-2011, 09:01 AM
Joe Patrick Joe Patrick is offline How to link a combobox to an access database? Windows 7 64bit How to link a combobox to an access database? Office 2007
Advanced Beginner
How to link a combobox to an access database?
 
Join Date: May 2011
Posts: 33
Joe Patrick is on a distinguished road
Default

Can anyone help me with this, please? Pretty please?
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
MM to Access 97 lost its link - broken by Windows Update? LesD Mail Merge 0 11-23-2010 07:13 AM
Excel 07-Access 03 Data Link Issue ddw23 Excel 0 08-20-2010 09:05 AM
How to link a combobox to an access database? Combobox manipulation vsempoux Word VBA 3 10-31-2009 08:58 AM
Excel to lookup Access Database PeterP Excel 1 06-11-2009 12:33 PM
How to link a combobox to an access database? Access database engine with Streets and Trips 2009 dreemsnake Misc 3 05-26-2009 10:25 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:07 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft