I need to open a binary file and save it to an access 4.0, but I can't figure out how to open it in a way that I can then move it into an ado recordset.
Printable View
I need to open a binary file and save it to an access 4.0, but I can't figure out how to open it in a way that I can then move it into an ado recordset.
Function FileText(ByVal filename As String) As String
Dim handle As Integer
' ensure that the file exists
If Len(Dir$(filename)) = 0 Then
Err.Raise 53 ' File not found
End If
' open in binary mode
handle = FreeFile
Open filename$ For Binary As #handle
' read the string and close the file
FileText = Space$(LOF(handle))
Get #handle, , FileText
Close #handle
End Function
now add this to your recordset
Iouri Boutchkine
[email protected]
Thanks, that worked and showed me that I didn't know how to save a binary file to an OLE field. I tried to do the way I save and transfer other fields: adorec!Picture = bFile I called your function like this: Call FileText(bFile) It might be because I need to dim bFile as a Variant, I'll try it tonight.
Rate it if it helped you
Iouri Boutchkine
[email protected]