patriciaxxx
Programmer
Below is my code which works if I take out
strSQL = "SELECT * FROM tblBlob WHERE Write = Yes "
and replace with
strSQL = "SELECT * FROM tblBlob"
but I want the where clause so I only have records where the field named WRITE is set to yes
The field named WRITE is a YES/NO field
So my question is what’s the correct way to code this line I've tried all variations
strSQL = "SELECT * FROM tblBlob WHERE Write = Yes "
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 = Yes "
rst.Open strSQL, CurrentProject.Connection, 1, 3
Do Until rst.EOF
If Not IsNull(rst!FileExt) Then
strFile = CurrentProject.Path & "\WRITE\" & 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 Su
strSQL = "SELECT * FROM tblBlob WHERE Write = Yes "
and replace with
strSQL = "SELECT * FROM tblBlob"
but I want the where clause so I only have records where the field named WRITE is set to yes
The field named WRITE is a YES/NO field
So my question is what’s the correct way to code this line I've tried all variations
strSQL = "SELECT * FROM tblBlob WHERE Write = Yes "
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 = Yes "
rst.Open strSQL, CurrentProject.Connection, 1, 3
Do Until rst.EOF
If Not IsNull(rst!FileExt) Then
strFile = CurrentProject.Path & "\WRITE\" & 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 Su