beforeupdate event , update multiple records

B

balu

dear friends,
privatesub myform_befreupdate(cancel as integer)
'ow to update multiple records to same table ay one event
'im usingcode
dim dbs as dao.database
dim myrs as dao.recordset
set dbs=dbs.openrecordset("table")
if not isnull(me.option textbox) and me.optiontextbox = " 2 recordsupdate"
then
'update first record set
myrs.addnew
myrs!x=me.field1
myes!y = me.field2
myrs.update
msgbox "first set updated
'update second set
myrs.addnew
myrs!x = me.text20
myrs!y=me.text21
myrs.update
msgbox " second set updated"
else
'update first record set
myrs.addnew
myrs!x=me.field1
myes!y = me.field2
myrs.update
msgbox "first set updated
end if
docmd.gotorecord acdataform,"myform",acnewrec
end sub
(1) my problom is form not seting to new record
(2) before update event not completing
can any one help me please to update multiple records at one event or on
click event
balu
 
M

Marshall Barton

balu said:
dear friends,
privatesub myform_befreupdate(cancel as integer)
'ow to update multiple records to same table ay one event
'im usingcode
dim dbs as dao.database
dim myrs as dao.recordset
set dbs=dbs.openrecordset("table")
if not isnull(me.option textbox) and me.optiontextbox = " 2 recordsupdate"
then
'update first record set
myrs.addnew
myrs!x=me.field1
myes!y = me.field2
myrs.update
msgbox "first set updated
'update second set
myrs.addnew
myrs!x = me.text20
myrs!y=me.text21
myrs.update
msgbox " second set updated"
else
'update first record set
myrs.addnew
myrs!x=me.field1
myes!y = me.field2
myrs.update
msgbox "first set updated
end if
docmd.gotorecord acdataform,"myform",acnewrec
end sub
(1) my problom is form not seting to new record
(2) before update event not completing
can any one help me please to update multiple records at one event or on
click event


When you post code, please make sure it compiles without
error by using Compile on the Debug menu.

Then use Copy/Paste to include the code in your message so
we don't waste time going back and forth discussing typos.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top