I hadn't noticed before (how could I have missed it? ), but the code from the tutorial does not actually extract the file from the database - instead it binds the picture to an Image control.

This wont work for other file types (and is a 'bad' method anyway), so you need some extra code. What you need to do is save the data to a file, and then use the file in whatever way is appropriate (possibly followed by deleting the file you saved).


Here is a sub I have written which saves the data to a file:
VB Code:
  1. Sub SaveFileFromDB(strFileName As String, fldPictureField As ADODB.Field)
  2. 'Save data from a OLE/BLOB field to a file
  3.  
  4. Dim intFileNum As Integer
  5. Dim bytChunk() As Byte
  6.  
  7.           'open file for writing
  8.   intFileNum = FreeFile
  9.   Open strFileName For Binary As #intFileNum
  10.           'get data from database
  11.   bytChunk() = fldPictureField.GetChunk(fldPictureField.ActualSize)
  12.           'write data to file
  13.   Put #intFileNum, , bytChunk()
  14.           'close the file
  15.   Close #intFileNum
  16.  
  17. End Sub
..and to use it, put the following code (or similar) in FillFields, replacing both lines that use "Image1":
VB Code:
  1. Call SaveFileFromDB(App.Path & "\temp.tmp", rs.Fields("Picture"))

One thing to note is that in this example I have used a file name that may not work for you (temp.tmp).. for example, the way you play the audio files may need the file to have the correct extension (eg: .wav , or .mp3).

What I would recommend is adding an extra field to the database table, called FileName (with a data type of: Text). When you save data in cmdAdd_Click, set the value of this field to the name of the file (with the extension, but not the path), using code like this:
VB Code:
  1. .Fields("FileName") = MyFileName   'where MyFileName is a variable containing the file name
..you can then re-save the file using the original name, eg:
VB Code:
  1. Call SaveFileFromDB(App.Path & "\" & rs.Fields("FileName").Value, rs.Fields("Picture"))