nathan sanders said:
Ken, Justin,
Thanks for your help. The joys of cut&paste! I have moved the code that
changes the record into my case statement. It still gets the same type
error on the .requery line. I changed the declaration of the recordset to
be dao.recordset (although I do not understand what that is about). new
revised code is below;
Sub process_bank_trans()
Dim MLIST, MESSTEXT, strsq1
Dim TXTDATA As dao.Recordset
Dim rstTrans, rstsumm As dao.Recordset
Dim dbs As Database
Dim strsql, strfil1 As String
Dim trnval As Currency
Dim trncount As Long
Dim hashtot As Long
Dim FILDATE As Date
Dim intreturn As Integer
'FILDATE = InputBox("Enter Payment Date")
Set dbs = CurrentDb
strsql = _
"SELECT * from indata"
Set TXTDATA = dbs.OpenRecordset(strsql)
Set rstTrans = dbs.OpenRecordset("transactions")
Set rstsumm = dbs.OpenRecordset("summary")
Do Until TXTDATA.EOF
FILDATE = TXTDATA!field1
trnval = TXTDATA!field2
Select Case Left(TXTDATA!field3, 20)
Case "DD CALTEX N Z LTD CA" 'handle
fuel account payment
trnval = 0 - trnval
rstTrans.AddNew
rstTrans!TRN_DATE = FILDATE
rstTrans!TRN_PAY = trnval
rstTrans!crednum = 81
rstTrans.Update
Case "DC AMERICAN EXPRESS "
With rstsumm
.Requery
.FindFirst "date= " & FILDATE
If .NoMatch = True Then
Else
.Edit
.Fields("amexpaid").Value = trnval
.Update
End If
End With
Thanks again
Nathan
Without commenting on the code as a whole, if you are getting type errors
then you need to watch your variable types and dimensioning them. I always
dimension each variable on a new line (sometimes with an explanation of what
it is) whereas you have dimensioned multiple variables on one line.
If you do this:
Dim strsql, strfil1 As String
You dimension the first as a variant and the second as a string. You could
use:
Dim strsql As String, strfil1 As String to dimension two strings
But I would just always use a new line:
Dim strsql As String
Dim strfil1 As String
By keeping a naming convention, you may help avoid confusion so make sure
all your recordsets begin with rst, dates with dte, etc, etc. Also don't
forget dbs is part of the DAO object library (i.e. DAO.Database)