Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RUN TIME ERROR 2176 THE SETTING FOR THIS PROPERTY IS TOO LONG 2

Status
Not open for further replies.

villica

Programmer
Feb 25, 2000
332
CA
Hello everyone,

I have created a list box that is supposed lists all the excel files, but I am getting the above error.

Are they any other ways


Dim MyFile As String, Stsql As String

MyFile = Dir("O:\BACKLOG*.xls")
Stsql = MyFile & ";"
Do While Not (MyFile = "")

MyFile = Dir

Stsql = Stsql & MyFile & ";"
Loop

Me.cbolist.RowSource = Stsql

villica
 
It would seem that you have too many items in the directory and have exceeded the limits for the control.
 
is there another way of doing the same thing

villica
 
Build the file list into a table and use that for your row source.
 
You may set the RowSourceType property of your control to a function.
Have a look at the VBA help for explanations about this feature.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi Remou, how do you build the file list into a table. Sample please

villica
 
Something like:
Code:
Dim MyFile As String, strSQL As String

strSQL = "Delete * From [tblTableName]"
CurrentDb.Execute strSQL

MyFile = Dir(CurrentProject.Path & "\") 'Dir("O:\BACKLOG*.xls")
    
    Do While Not (MyFile = "")
  
    MyFile = Dir
        strSQL = "Insert Into [tblTableName] ( [FileName] ) Values ('"
    If Len(Trim(MyFile)) > 255 Then
        strSQL = strSQL & "Error: " & Left(Replace(MyFile, "''", "'"), 240) & "')"
    Else
        strSQL = strSQL & Replace(MyFile, "''", "'") & "')"
    End If
    CurrentDb.Execute strSQL

Loop
 
Me.cbolist.RowSource = "[tblTableName]"
End Sub
 
Hi Remou, I am trying the code sample above, is the replace command access 97 or 2000. I am using access 97. I do not have access 2000 on my system so i can not verify.


villica
 
thank you so much Remou and PHV. I would like also to thank the person who wrote the replace function.

villica
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top