Can I run an append query from inside a form?

G

Gretchen

I have a form and a sub form that are linked on two fields - LabID and
AlphaID. I have a query that updates the subform. The query works fine
however the new records that I added via my update form are not visible in
the form until I close out and reopen the form. It seems that you have to
refresh the form in order to see the additions when they added via an append
query. Any thoughts/suggestions as to how I can either write a macro to
automatically refresh my form or do it another way? Thanks.
 
K

Klatuu

You can requery the form after the updates to the table are complete. You
also have to add some code to keep your form on the current record. If you
do not, after the requery, the form will be positioned on the first record.

strKeyField = Me.txtSomeControl 'This should be the primary key of your
main form.

Me.Requery
With Me.RecordsetClone
.FindFirst "[TableKeyField] = '" & strKeyField & "'"
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
 
A

Al Campagna

Gretchen,
Use Requery agaisnt the subform after the query is run.
Forms!frmYourMainForm!frmYourSubForm.Requery
 
G

Gretchen

All this code is great however I'm not a programmer! I wrote a macro to run
the query and I can't find a macro that will do the requery as you write it.
I'm a pretty elementary user of access!
 
G

Gretchen

Additionally,
I would like the append query to use a LabID and a LabAlpha that are part of
my main form. When I use that as criteria for the "Apply Filter" macro it
appends everything, it does not look for my criteria of a specific LabID.
When I manually enter the value it works fine.
 
A

Al Campagna

Gretchen,
Macros does have a Requery command. You fill in the Form name in the argument
provided.
Forms!frmYourMainForm!frmYourSubForm
See Help on Requery Action.
 

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