Combo box help!!!!

woknick

Registered User.
Local time
Today, 11:23
Joined
Sep 25, 2004
Messages
85
I want to open a txt file and place the contents of that textfile into c aombo box. I am having some trouble because there is not an additem method. Here is my code so far.

Private Sub AdditionalAccounts_GotFocus()
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim Item As String
Dim Account As String
Dim FileName As String
Dim Drive As String
Drive = "c:\"
FileName = AccountNum.Value
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(Drive & FileName & ".txt", ForReading, TristateFalse)
Do Until EOF(1) = True
Input #1, Item
cboAccountNum
Loop
f.Close

End Sub


Please help, im stuck

Thanks in advance
 
How many lines are there in your text file ?

I read a text file with similar code to yours:

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts, s


Set fs = CreateObject("Scripting.FileSystemObject")

Set f = fs.getfile("C:\Windows\textfilename.txt")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
s = ts.readline

'Added line:

cboBoxname.Rowsource = s
cboBoxName.Requery

ts.Close

As for reading the second line ???

HTH

Dave
 
The text file stores account numbers, so it could potentially hold 1-10 5 digit strings.
 

Users who are viewing this thread

Back
Top Bottom