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

Methode open of object recorset failed

Status
Not open for further replies.

patriciaxxx

Programmer
Jan 30, 2012
277
GB
Below is my code I just can’t get the following line coded properly
strSQL = "SELECT * FROM tblBlob WHERE Write = True"
The field Write is a Yes/No field

Private Sub cmdExtract_Click()
On Error GoTo Err_Handler
Dim strSQL As String
Dim rst As Object 'ADODB.Recordset
Dim strFile As String

Set rst = CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tblBlob WHERE Write = True"
rst.Open strSQL, CurrentProject.Connection, 1, 3
Do Until rst.EOF
If Not IsNull(rst!FileExt) Then
strFile = CurrentProject.Path & "\files\" & rst!FileName & "." & rst!FileExt
End If
WriteBinaryFile rst.Fields("BLOB").Value, strFile
rst.MoveNext
Loop
MsgBox rst.RecordCount & " records have been extracted."

Exit_Handler:
rst.Close
Set rst = Nothing
Exit Sub

Err_Handler:
MsgBox Err.Description, vbOKOnly + vbExclamation, "ERROR: " & Err.Number
Resume Exit_Handler

End Sub
 
Write" is a reserved word in JET 4.0. Try
Code:
strSQL = "SELECT * FROM tblBlob WHERE [b][red][[/red][/b]Write[b][red]][/red][/b] = True"
 
Too slow golom. Already answered in Patriociaxxx's thread705-1696862 ;-)

Patriciaxxx, you might want to keep a single problem in a single thread.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top