How do you requery to make data available for use?

J

John F

Table "A" is the data for form "A".
Table "B" is the data for subform "B".
Table "C" is a lookup for a field in table "B".
Form "A" is a regular form.
Form "B" is a datasheet style form.

Control button on form "A" which opens a form to update contents of table "C".
After closeing the form from which table "C" was eddited how do you requery
to make the newly added information to the lookup is available for use?

DoCmd.Requery does not work.
DoCmd.Requery sfrmBookAuthor does not work.
 
D

Dirk Goldgar

John F said:
Table "A" is the data for form "A".
Table "B" is the data for subform "B".
Table "C" is a lookup for a field in table "B".
Form "A" is a regular form.
Form "B" is a datasheet style form.

Control button on form "A" which opens a form to update contents of table
"C".
After closeing the form from which table "C" was eddited how do you
requery
to make the newly added information to the lookup is available for use?

DoCmd.Requery does not work.
DoCmd.Requery sfrmBookAuthor does not work.


You need to requery the control on the subform that uses table C as its
rowsource. You haven't named that control, though. Suppose that its name
is "D". Then the general form of the statement is:

Forms!A!B.Form!D.Requery

That is assuming that "B" is actually the name of the subform control on A
that displays the form object "B". That may not be the case; you should
check.

If the statement would be executed in the module of form A, you can
short-cut it like this:

Me.B.Form!D.Requery

Note, though, that if you are using the same event procedure (on form A) to
open the form that edits C and then requery the control, you'll need to open
that form in dialog mode; e.g.,

DoCmd.OpenForm "FormToEditC", WindowMode:=acDialog
Me.B.Form!D.Requery
 
J

John F

Thanks problem solved. But now this brings up another question.

Private Sub Command11_Click()

refind = BookID
Forms!frmBooks!frmBookAuthor!Authors.Requery
Forms!frmBooks.Requery
DoCmd.GoToRecord , "frmBooks", , refind

End Sub

With the above code why does it go to the record after the one stored in
refind?
 
D

Dirk Goldgar

John F said:
Thanks problem solved. But now this brings up another question.

Private Sub Command11_Click()

refind = BookID
Forms!frmBooks!frmBookAuthor!Authors.Requery
Forms!frmBooks.Requery
DoCmd.GoToRecord , "frmBooks", , refind

End Sub

With the above code why does it go to the record after the one stored in
refind?


It doesn't look to me like you are using the GoToRecord method correctly.
Check the help file entry for that method. Your code is telling it the
current form -- whatever it is -- to advance (refind) records. Is that what
you had in mind? If BookID is the primary key of the current record, and
you want to requery the current form and then return to that record, then
your code might look like this:

refind = Me.BookID
Me.Requery
Me.Recordset.FindFirst "BookID=" & refind

That's assuming that BookID is a numeric field.
 

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