P
PaulB50
G'day I am having trouble setting up access basic routine to look for a jpg
file, and save it to a table field. I am handling the table record as a class
object & all is fine with all other data types except picture files.
Table is tblCheque with a heap of fields
ChequeID as autonumber
Name as string
RecDate as date
ChequeImage as oleobject
The class object i(claStuff) s defined with Get & Let properties as well as
load (from table) & Save methods. these again work for all other datatypes.
So I get a recordset that need picture updates required - that works; & step
through them sequentially to the eof, tested that without the picture code &
the code works.
Sub StoreImages(MyBankAccountID As Long)
'The object of this routine is to accept the bank account id, the cheque
numbers
'& the image MyImagePath of the jpg files that comprise the evidence set
for these transactions
Dim MyDb As DAO.Database
Dim rstCheques As DAO.Recordset
Dim MyCheque As New claCheque
Dim strRecordset As String
Dim CheqID As Long
Dim Cheqnum As Long
Dim ImagePath As String
Dim RecCount As Long
Set MyDb = CurrentDb
strRecordset = "SELECT tblCheque.ChequeID, tblCheque.CaseID,
tblCheque.BankAccountID, tblCheque.ChequeNum" _
& " FROM tblCheque" _
& " WHERE (tblCheque.CaseID = 1) And
(tblCheque.BankAccountID = " & MyBankAccountID & ")" _
& " ORDER BY tblCheque.ChequeID"
Set rstCheques = MyDb.OpenRecordset(strRecordset, dbOpenDynaset)
With rstCheques
RecCount = .RecordCount
Do Until CheqID > 5 '.EOF
CheqID = ![ChequeID]
Cheqnum = ![ChequeNum]
With MyCheque
MyCheque.ChequeID = CheqID
If MyCheque.Load Then
ImagePath = GetTif(Cheqnum, "Butt")
MyCheque.ButtImage = LoadPicture(ImagePath)
ImagePath = GetTif(Cheqnum, "Face")
MyCheque.ChequeImage = LoadPicture(ImagePath)
ImagePath = GetTif(Cheqnum, "Back")
MyCheque.ReverseImage = LoadPicture(ImagePath)
Else
Exit Do
End If
MyCheque.Save
End With 'MyCheque
.MoveNext
RecCount = RecCount - 1
Loop
End With 'rstCheques
rstCheques.Close
End Sub
How do I declare and set the variables to achieve this, I expect that they
will need to be set in the class object
regards
file, and save it to a table field. I am handling the table record as a class
object & all is fine with all other data types except picture files.
Table is tblCheque with a heap of fields
ChequeID as autonumber
Name as string
RecDate as date
ChequeImage as oleobject
The class object i(claStuff) s defined with Get & Let properties as well as
load (from table) & Save methods. these again work for all other datatypes.
So I get a recordset that need picture updates required - that works; & step
through them sequentially to the eof, tested that without the picture code &
the code works.
Sub StoreImages(MyBankAccountID As Long)
'The object of this routine is to accept the bank account id, the cheque
numbers
'& the image MyImagePath of the jpg files that comprise the evidence set
for these transactions
Dim MyDb As DAO.Database
Dim rstCheques As DAO.Recordset
Dim MyCheque As New claCheque
Dim strRecordset As String
Dim CheqID As Long
Dim Cheqnum As Long
Dim ImagePath As String
Dim RecCount As Long
Set MyDb = CurrentDb
strRecordset = "SELECT tblCheque.ChequeID, tblCheque.CaseID,
tblCheque.BankAccountID, tblCheque.ChequeNum" _
& " FROM tblCheque" _
& " WHERE (tblCheque.CaseID = 1) And
(tblCheque.BankAccountID = " & MyBankAccountID & ")" _
& " ORDER BY tblCheque.ChequeID"
Set rstCheques = MyDb.OpenRecordset(strRecordset, dbOpenDynaset)
With rstCheques
RecCount = .RecordCount
Do Until CheqID > 5 '.EOF
CheqID = ![ChequeID]
Cheqnum = ![ChequeNum]
With MyCheque
MyCheque.ChequeID = CheqID
If MyCheque.Load Then
ImagePath = GetTif(Cheqnum, "Butt")
MyCheque.ButtImage = LoadPicture(ImagePath)
ImagePath = GetTif(Cheqnum, "Face")
MyCheque.ChequeImage = LoadPicture(ImagePath)
ImagePath = GetTif(Cheqnum, "Back")
MyCheque.ReverseImage = LoadPicture(ImagePath)
Else
Exit Do
End If
MyCheque.Save
End With 'MyCheque
.MoveNext
RecCount = RecCount - 1
Loop
End With 'rstCheques
rstCheques.Close
End Sub
How do I declare and set the variables to achieve this, I expect that they
will need to be set in the class object
regards