Is it possible to requery invisibly?

D

Daniel

Hi,


I have this copy button on my form that when it is clicked
it asks the user how many copies it wants. The problem I
have is that if I don't requery the form I can not make
multiple copies of the record. (The primary key is
changed). The copy works when I add Me.requery after
every copy (in other words, I requery the form at the end
of the for loop). THe problem with the requery is that it
sets the form back to the first record and then I have to
set my current record back to the orginal record (all this
is in a for loop).

SO when the copying is performed, it looks like its
flashing back though I don't want it to do that. If I
could only requery with out showing it, it would be great.

The above as probably a little complicated to explain but
the main algorithm goes:

x= What ever user enters.
for y=1 to x
copy record
change to the copy the primary key
save the record

Me.Requery

DoCmd.GoToRecord ---> [Orignal record copying]
next y

Thank you
 
E

Erez

hi there
i dont think you can invisibly requery the form
but you can have the updates done on the form's underlying
recordset, instead of the form itself, and then requery
only once after it all finished.

so instead of something like:
x= What ever user enters.
for y=1 to x
copy record
change to the copy the primary key
save the record
Me.Requery
DoCmd.GoToRecord ---> [Orignal record copying]
next y

you can do:
x= What ever user enters.
fld1=info1 (save the data you want from this specific
record)
fld2=info2 (...same)
....
for y=1 to x
Me.RecordSet.AddNew (if the primarykey is AutoNumber it
will be added automatically each time)
Me.RecordSet!info1=fld1 (insert the data you saved)
Me.RecordSet!info2=fld2 (insert the data you saved)
Me.RecordSet!info3=fld3 (insert the data you saved)
Me.RecordSet.Update (update the recordset without
requerying)
next y
Me.Requery
DoCmd.GoToRecord ---> [Orignal record copying]
(to come back to where you were, if you still need it)

hope i got it right, and it makes sense to you.
Erez.
 
J

John Vinson

SO when the copying is performed, it looks like its
flashing back though I don't want it to do that. If I
could only requery with out showing it, it would be great.

You can turn off screen updates by putting

Application.Echo False

before your loop; be sure to put

Application.Echo True

after or it will freeze the screen indefinately!

I strongly suspect that a single Append query without any
record-by-record thrashing would be both possible and much more
efficient, though! Care to post your code?
 
D

Daniel

Thanks Erez, but I forgot to say that my form also needs
to copy a subform. Now the bigger problem is that the
subform can change depending on the model type that the
record has. So it is hard to copy the subform and to know
which subform.
 
J

John Vinson

Thanks Erez, but I forgot to say that my form also needs
to copy a subform. Now the bigger problem is that the
subform can change depending on the model type that the
record has. So it is hard to copy the subform and to know
which subform.

This is making me increasingly queasy. A Form IS JUST A WINDOW. You
can't copy a Form, or a Subform! You can copy the *DATA IN A TABLE*,
which may or may not be displayed on a Form; but to do so, you would
use a Query or Queries to move the data around in the Tables, and
after you're done moving the data, requery the form in which that
table data is displayed.
 

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