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

confused about opening a recordset and findfirst

Status
Not open for further replies.

newnoviceuser

Programmer
Jan 4, 2003
63
US
I am so confused if fixed the problem but this keeps happening. this is the code I have and it worked fine
but then i added at the end of rst!checks I added +rst!vouchers when I did I got an error on the rst.findfirst
it said something along the lines of unable to do the operation with this object. ai cant remember exactly
anyway I changed the "sheet" to "select * from sheet"
and it worked fine no error then i changed it back to "sheet" so i could write down the error to ask and it didn't crash it still worked fine. why? i think i am going crazy. now i cant even make it give me the error. but i want to understand
Sub cashclose()
Dim db As Database
Dim rst As Recordset
Dim strcriteria As String
strcriteria = "sheedate = date()"
Set db = CurrentDb
Set rst = db.OpenRecordset("sheet")
rst.FindFirst strcriteria
If rst.NoMatch Then
MsgBox "error"
End If
rst.Edit
rst!total = rst!C100 + (rst!C50 * 0.5) + (rst!C25 * 0.25) + (rst!C10 * 0.1) + (rst!C5 * 0.05) + (rst!C1 * 0.01) + (rst!D100 * 100)
rst!total = rst!total + (rst!D50 * 50) + (rst!D20 * 20) + (rst!D10 * 10) + (rst!D5 * 5) + rst!D1 + rst!CURRENCY + rst!COINS + rst!CHECKS
rst.Update
rst.Close
End Sub
 
[tt]
I dunno...but,

Did you copy and paste your code? If so, then you may want to change this line:

strcriteria = "sheedate = date()"


to

strcriteria = "sheetdate = date()" [glasses][tt] Gus Brunston - Access2000(DAO)[/tt] Intermediate skills.
 
Why are you doing this at all ?????

All you seem to be doing is applying some Maths to values in fields in the current record and then storing the result in THE SAME RECORD !!!!

This is a big No-No. - There is no point. - other than setting yourself up for data integrity errors in the future.


G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
no what it actually does is , on close,total the sheet at the end then it carries it over to the next record. i didnt know of any other way to do it.
the code was right it has worked for months but they changed the vouchers part they wanted it to carry over in the total before they didnt want it to. adding the +rst!vouchers had nothing to do with the findfirst command but this is the 4th or 5th time ive changed just a word or 2 of code and the findfirst stops working and i spend hours trying to fix it well i did until i finally tried the select its worked everytime so far. but id still like to know why for my own knowledge I am very new to this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top