From: macrojunkie on
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
[/code]

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!!!
From: Marshall Barton on
macrojunkie wrote:

>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
>[/code]
>
>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

--
Marsh
MVP [MS Access]
From: Daryl S on
Macrojunkie -

Maybe you just want to save the current record before doing anything else
when the user clicks on the command button. Once the record is saved, then
open the new form, and the new record will be available.

--
Daryl S


"macrojunkie" wrote:

> 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
> [/code]
>
> 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!!!
> .
>
From: NEWER USER on
In the After Update Event property for that field being updated try:

Me.subform name.Form.Requery

"macrojunkie" wrote:

> 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
> [/code]
>
> 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!!!
> .
>
From: macrojunkie on
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!!!