VBA for edit record not working

sacacompany

Member
Local time
Today, 20:51
Joined
Dec 28, 2022
Messages
31
please help me locate issue in following code.....

Dim Records As DAO.Recordset
Dim Records1 As DAO.Recordset

Set Records1 = CurrentDb.OpenRecordset("Select ID, Paid From RentInvoice where ID = " & Me.Text6, dbOpenDynaset, dbAppendOnly)
Debug.Print ID, paid
With Records1
Records1.Edit
Records1!paid = True
Records1.Update
Set Records1 = Nothing

End With
 
What is the issue - error message, wrong result, nothing happens?

Why do you need to use code to edit record? Not using a bound form?

Do you really need a yes/no check field? Don't you have DatePaid and maybe CheckNum fields?
 
Last edited:
You can't use dbAppendOnly to update an existing record.
Why not just use an update query instead of a recordset?
 
thanks for the input Pat
your advice is well taken
regarding bound form ...i don't have good experience with them as i keep my tables on the local server in separate access files and the front end distributed to all staff. unbound forms are working fine and fast for me so far. if you have any advice i would love to have it
 
Well, your above reply is theoretically correct ... I have been developing applications on Access since 1997. it's a long journey from bound to unbound forms. You are right in saying that I bypass RAD. But this is done to deal with less educated users and slow networks in enterprises. the ultimate blame is given to the application instead of fixing the network. So I purposely switched to unbound forms although these require more of my development time and effort but save me from user usual complaints that the Access app runs sometimes and crashed other times!! But having said all this your point is very well taken. I now will use bound forms to try to work around and stop fetching all records on loading of form. Can you have any suggestions..thanks in advance
 
Not the first experienced developer I've seen express preference for unbound forms. You still get to take some advantage of RAD, at least in building objects, just not the data handling part of forms. Access query designer is a convenient asset as well.
 
i keep my tables on the local server in separate access files
Why different files as backends?
Because of the mass of data (2GB limit), because the data have nothing to do with each other, or because of the overview?

After 20 years you should be familiar with the DAO constants to use.
Likewise, I would argue that a Recordset1.Close is missing. Unless one fully trusts how garbage collection works, closing the recordset is more important than removing the reference.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom