"Save record" button in a subform to also refresh the data in the main form

osullipa

Registered User.
Local time
Today, 11:35
Joined
Dec 7, 2004
Messages
31
I have a form which contains one subform. On the subform I have a command button which saves the record just entered. On the main form I have a "refresh form data" button which updates the main form so that the calculated controls can show the correct results based on the data just entered?

Can anyone tell me how I can get the "save record" button in the subform to subsequently refresh the data in the main form as well, thus saving a button???


Many thanks.


Peter
 
I think, to have the parent form recalculate calculated controls, you could use the following in your subform refresh button event procedure

me.parent.recalc

which is supposed to recalculate. Have it perform after the subform refresh, though. A refresh, could be performed the same way

me.parent.refresh
 
RoyVidar said:
I think, to have the parent form recalculate calculated controls, you could use the following in your subform refresh button event procedure

me.parent.recalc

which is supposed to recalculate. Have it perform after the subform refresh, though. A refresh, could be performed the same way

me.parent.refresh

Hi Roy

I'm not sure how to do this. Can you advise further. Thanks.

Regards


Peter
 
maxmangion said:
simply put that piece of code on the onClick event of your button in question.
Sorry about the delayed response, I've been ill. Anyway I tried putting the code in the OnClick Event of my Erase button in the subform and got the message "Microsoft Office cannot find the macro ME"

What am I doing wrong? Thanks again.

Peter
 
Did you put it in the event property? It would need to be in the code.

If so, delete whatever is in the property event, at the right of the line, select the button with three dots, select code builder, and insert the code where the cursor is.
 
RoyVidar said:
Did you put it in the event property? It would need to be in the code.

If so, delete whatever is in the property event, at the right of the line, select the button with three dots, select code builder, and insert the code where the cursor is.

Hi Roy

Sorry to be a pain, but I'm beginning to feel a bit dense!!!!! I have the default save record button on the subform, which I constructed using the command button icon on the form builder tools.

When I go into the properties for that button and click on the "3 button" icon for the "on click" item, I only get a page of "visual basic" which includes the code for the button as shown below - not the option for the code builder.

Private Sub Command69_Click()
On Error GoTo Err_Command69_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_Command69_Click:
Exit Sub

Err_Command69_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command69_Click

End Sub

What am I doing wrong?

Peter
 
Code:
Private Sub Command69_Click()
On Error GoTo Err_Command69_Click
    docmd.runcommand accmdsaverecord
    me.parent.recalc '  or
    ' me.parent.refresh

Exit_Command69_Click:
    Exit Sub
Err_Command69_Click:
    MsgBox Err.DESCRIPTION
    Resume Exit_Command69_Click
End Sub
 
RoyVidar said:
Code:
Private Sub Command69_Click()
On Error GoTo Err_Command69_Click
    docmd.runcommand accmdsaverecord
    me.parent.recalc '  or
    ' me.parent.refresh

Exit_Command69_Click:
    Exit Sub
Err_Command69_Click:
    MsgBox Err.DESCRIPTION
    Resume Exit_Command69_Click
End Sub


Thanks Roy. I can see that I need to learn a lot more about this! Thanks again for your assistance.

Peter
 

Users who are viewing this thread

Back
Top Bottom