beforeupdate event , update multiple records

  • Thread starter Thread starter balu
  • Start date Start date
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
 
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.
 
Back
Top