Select option in a drop-down menu from excel file?

Posted on 2003-03-04
Medium Priority
Last Modified: 2010-04-07
I'm making a database (if you can call it that) the saves the user input into an excel file but I'm trying to load it back into the form.  Does anyone know how to do this with a drop down menu?  I've gotten desperate and resorted to using radio buttons...  
I hope it's easy and I just don't get it.
Question by:lemonduck
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 11

Expert Comment

ID: 8068125
when you say save into an Excel file I belive you mean a simple text file with one line of code.  So use code something similar to that. (refer to the second function)

Private Sub SaveDataToExcel()
    Dim strExcelFile As String
    Dim ArrayList(10) As String ' temporary sample array to save
    Dim i As Long
    strExcelFile = "C:\data.xls"
    ' populate array with dummy data
    For i = 0 To 10
        ArrayList(i) = Str(i)
    Next i
    Open strExcelFile For Output As #1
    'now save the array
    For i = 0 To 10
        Write #1, ArrayList(i)
    Next i

    Close #1
End Sub

Private Sub LoadDataToCombo()
    On Error GoTo LoadErr
    Dim strExcelFile As String
    Dim strComboItem As String
    Dim i As Long
    strExcelFile = "C:\data.xls"
    Open strExcelFile For Input As #1
    'now save the array
    While (Not EOF(1))  ' lopp until the end of the file
        Input #1, strComboItem  ' get each line (combo item)
        If (Trim(strComboItem) <> "") Then  ' if there is data
            combo1.AddItem strComboItem
        End If

    Close #1
    Exit Sub
    MsgBox "Error loading Data to the list" & vbcrl & Err.Number & ": " & Err.Description
    On Error GoTo 0
End Sub

Hope this is useful.  Good Luck!
LVL 49

Expert Comment

ID: 9046854
Hi lemonduck,
It appears that you have forgotten to close this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Save as PAQ -- No Refund.

lemonduck, Please DO NOT accept THIS comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
DanRollins -- EE database cleanup volunteer

Accepted Solution

YensidMod earned 0 total points
ID: 9151041
Question is PAQ'd and no points refunded.

Community Support Moderator @Experts Exchange

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question