Refresh Subform Current Record?


M

macrojunkie

I have a main form with a bunch of subforms on a tab control. For a
subform, it has command buttons to launch forms based on those "sub"
records.

So we have frmMain and frmSub

On frmSub I have a nice little code that let's the users know how many
sub records they have:
Code:
Private Sub Form_Current()
If CStr(Me.CurrentRecord) > CStr(Me.RecordsetClone.RecordCount) Then
Me!txtCurrRec = "New Sub Record"
Else
Me!txtCurrRec = CStr(Me.CurrentRecord) & " of " & _
CStr(Me.RecordsetClone.RecordCount) & " Sub Records"
End If
End Sub

My issue right now is that a user can start entering in information in
the fields of the subform. If they go to hit one of the command
buttons to open a related "sub-sub" form for that new record, it says
there is no new record yet. I have to navigate to a new record and
come back to get the subform to refresh and save the record that was
just entered. How can I get the record to update the minute a user
starts entering in any information on the sub form? Any thoughts
please?

Thanks!!!
 
Ad

Advertisements

M

Marshall Barton

macrojunkie said:
I have a main form with a bunch of subforms on a tab control. For a
subform, it has command buttons to launch forms based on those "sub"
records.

So we have frmMain and frmSub

On frmSub I have a nice little code that let's the users know how many
sub records they have:
Code:
Private Sub Form_Current()
If CStr(Me.CurrentRecord) > CStr(Me.RecordsetClone.RecordCount) Then
Me!txtCurrRec = "New Sub Record"
Else
Me!txtCurrRec = CStr(Me.CurrentRecord) & " of " & _
CStr(Me.RecordsetClone.RecordCount) & " Sub Records"
End If
End Sub

My issue right now is that a user can start entering in information in
the fields of the subform. If they go to hit one of the command
buttons to open a related "sub-sub" form for that new record, it says
there is no new record yet. I have to navigate to a new record and
come back to get the subform to refresh and save the record that was
just entered. How can I get the record to update the minute a user
starts entering in any information on the sub form?


A record is not "finished" until it has been saved to its
table. Navigating to another record causes Access to
implicitly save any changes to a record. Moving the focus
from the main form to a subform or vice versa will also
implicitly save any changes to the current record.

Another way could be for your command buttons to explicitly
force the current record to be saved using this line of
code:
If Me.Dirty Then Me.Dirty = False
 
N

NEWER USER

In the After Update Event property for that field being updated try:

Me.subform name.Form.Requery
 
Ad

Advertisements

M

macrojunkie

Thank you for all of the quick responses. I ended up putting the
DoCmd.RunCommand acCmdSaveRecord into the after update of the first
field on the form. As long as they start to fill out a record, it
will save it and update that recordset for having that record, so they
can launch subform buttons tying to that record.

Thanks all!!!
 

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