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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a list of files in Access 2002

Status
Not open for further replies.

xBaboon

Technical User
Dec 5, 2002
2
GB
I have a small client managment database on the go, and what I want to be able to do is add a button on the form which when clicked opens a file browser which allows the user to find and choose a quote (word doc). The filename/location is then added to a listbox/textbox on the form. Then there is a second button, which when clicked opens Word and then opens the document. The Sub I've made which opens the document works perfectly, but the filechoosing part doesn't seem to.

It drops the name/location of the file into a listbox, but once you move to another record in the database, it carries the same name/location across to that one. Basically it seems to hold one filename and once you close and open the database again, it's gone. What I want it to do basically is take the filename/location for each record and store it in my main table along with all the other customer details. Here is the 2 Subs I currently use (the first was borrowed from the MS knowledgebase pages)...

[tt]Private Sub cmdFileDialog_Click()

Dim fDialog As Office.FileDialog
Dim Varfile As Variant

FileList.RowSource = ""
FileList.RowSourceType = "Value List"
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = False

.Title = "Please select a file"

.Filters.Clear
.Filters.Add "Word Document", "*.doc"
.Filters.Add "All Files", "*.*"

If .Show = True Then
For Each Varfile In .SelectedItems
FileList.AddItem Varfile
Next
Else
MsgBox "You didn't choose anything"
End If
End With
End Sub

Private Sub openQuote_Click()

Dim wdApp As Word.Application
Set wdApp = New Word.Application
' Check to see if a file has been selected
If IsNull(FileList) Then
MsgBox "You must select a file from the list"
End
Else
wdApp.Visible = True
wdApp.Documents.Open (FileList)
wdApp.ActiveWindow.SetFocus
Set wdApp = Nothing
End If

End Sub
[/tt]
Has anyone got any ideas as to why what's happening is happening, and even better a solution?

Thanks in advance
 
it sounds like the text box isn't a bound control...

check into that...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
It's actually a listbox rather than a text box right now (to allow mulitiple files to be selected). I've made a field in my main table to store the information, and bound the control source of the listbox to that field, but nothing happens :/

It just doesnt seem to write any information to the field.
 
ahh... now i understand...

When you have a list box setup as a multi select box, it will alwas return null...

I've had this same problem...

You need to cycle through the collection and pull each file name...

I have an mdb that uses this if you'd like to see it, I would be happy to email it to you...

I just need to pull the usefull part into it's own mdb for you...

fyi, I use access 2k.

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top