Subform requery

G

Guest

I'm sure you answer this over and over again. I did search first and found
not a suitable answer...

I have a header table and detail table linked by ID. In a form, I launch
another form that adds a header and creates loads of detail. I close that
form and return to the caller form. The Caller form shows the header and
detail in a form/subform format, which works.

When I get back to the Caller form, he can't see the new added header
record. If there were four records when he called the Add form, there are
still four records, even though the Add form may have added several headers.

I have fired the me.requery method on GotFocus for the Caller form. No joy.
I've fired the me.refresh method as well. No joy. I literally have to close
the Caller form and reopen it to see the new header record(s).

Only strange thing (if one considers it strange...) is that I'm using ADO to
update the header (and detail) tables.

Record source for the caller is only the header table. No filters or sorts.

Ideas?
TIA -- Jim
 
B

Baz

Try this:

In the caller form, specify WindowMode:=acDialog in the OpenForm statement.
On the very next line, do your Me.Requery.

Something like this:

DoCmd.OpenForm "frmSomeForm", WindowMode:=acDialog
Me.Requery
 
G

Guest

I tried it. It opened the called form in a what looked like datasheet format,
with no controls on it. I have buttons and bells and whistles on that form,
as well as a sequence that must be followed adding the records. Won't be
suitable. Wish I could post pictures...
 
B

Baz

You are supposed to add the "WindowMode:=acDialog" argument to whatever
arguments you are already using in your DoCmd.OpenForm statement. Since you
didn't post your code, I couldn't include whatever you are already doing in
my example, but it looks like you've missed something out. Always helps
when people post their code.

It's a simple, bog standard technique, I've been doing it 10 times a day for
years. You've got something else wrong.
 
G

Guest

Baz,
Thank you for your patience with my scatterbrained self. You're right, it
worked. I'll post the code. I did the wizard to set up the button, so that's
why the strange structure. When I tested the code earlier, I put the acDialog
in the wrong argument. Thus the problem. Thanks for sticking with me.

Private Sub btnAddBatch_Click()
On Error GoTo Err_btnAddBatch_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmAddBatch"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, WindowMode:=acDialog
Me.Requery

Exit_btnAddBatch_Click:
Exit Sub

Err_btnAddBatch_Click:
MsgBox err.Description
Resume Exit_btnAddBatch_Click

End Sub
 
B

Baz

No worries, pleased to be of assistance.

JimS said:
Baz,
Thank you for your patience with my scatterbrained self. You're right, it
worked. I'll post the code. I did the wizard to set up the button, so that's
why the strange structure. When I tested the code earlier, I put the acDialog
in the wrong argument. Thus the problem. Thanks for sticking with me.

Private Sub btnAddBatch_Click()
On Error GoTo Err_btnAddBatch_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmAddBatch"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, WindowMode:=acDialog
Me.Requery

Exit_btnAddBatch_Click:
Exit Sub

Err_btnAddBatch_Click:
MsgBox err.Description
Resume Exit_btnAddBatch_Click

End Sub
 

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