Changing records on unbound forms

VBAhole22

Registered User.
Local time
Today, 19:05
Joined
Jan 18, 2002
Messages
117
I have started using unbound forms more and more on my user data entry forms because I like the control factor of being able to collect, check and submit all of the data at once with one clean SQL statement. That said, I have a few small problems when I do this. What code do I put on the 'Enter Record' button that a user hits to submit a completed form(one record)? It needs to submit the record and clear the form for the next record.
Any suggestions?
 
private sub YourButton_Click()
dim db as dao.database
dim rs as dao.recordset

set db=currentdb
set rs=db.openrecordset("YourTableName",dbopendynaset)
rs.addnew
rs.fields(0) = me!Field1Name
rs.fields(1) = me!field2Name
etc.
or
rs!Field1Name = me!Field1Name
rs.Field2Name = me!field2Name
etc.
rs.update
rs.close
db.close
set rs=nothing
set db=nothing
end sub
 

Users who are viewing this thread

Back
Top Bottom