A question of filenames

  • Thread starter Thread starter Andy Levy
  • Start date Start date
A

Andy Levy

Hi

I have a combobox field in my table that holds the name of an image file
(e.g. picture1.jpg)

The user can select which image they want by selecting from the drop down
list or inputting it themselves.

When the combobox gets focus it retrieves the names of all the images in the
'images' directory, and lists the file names row by row.

However... the combobox rowsource has a limit on size apparently (based on
an error i receive when i have lots of images in the 'images' directory. Is
there another way i can let the user choose a file and get the filename in a
textbox?


Here is my current code.

Public Function ListFiles() As String
'This function builds up the rowsource string that goes into the combobox.
Dim strQuote As String
strQuote = Chr$(34)

Dim fn As String
Dim str As String
Dim projPath As String

projPath = CurrentProject.Path & "\images\*.jpg"

fn = Dir$(projPath)
While Len(fn)
str = str & "; " & fn
fn = Dir$
Wend
str = strQuote & Right$(str, Len(str) - 2) & strQuote

ListFiles = str
End Function



Private Sub imageRef_GotFocus()
'Living
'This function sets the rowsource of the combobox when it gets focus.
Me.imageRef.RowSourceType = "Value List"
Me.imageRef.RowSource = Eval(ListFiles())
End Sub


Thanks

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top