Help! Re: Save and Refresh (in separate subforms)

C

Chris

IT DOESN'T WORK !!!
HELP, PLEASE !!!
I tried and I get the error message: Microsoft Access can't find the field
'NameOfSecondSubformControl' in your expression.
Here is the code used by me:

Private Sub Save_Click()
On Error GoTo Err_Salvare_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me![Intr2-e].Form.Requery
Exit_Save_Click:
Exit Sub

Err_Save_Click:
MsgBox Err.Description
Resume Exit_Salvare_Click

End Sub

using
Requery
and
ShowAllRecords actions ), after every record enterd from the first subform.

Is any posibillity to do these things with a single command button?
How?

Chris,

put this in the first command button's OnClick event right after the
save command:

Me![NameOfSecondSubformControl].Form.Requery

Also I'd consider making a single subform for everything, but for this
I know too few from the purpose.

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 
N

Neil

Chris,

This might be easier to read for you and will give the same effect:

Private Sub Save_Click()
On Error GoTo Err_Save_Click

' Check to see if subform 1 has been saved
If Forms!MainFormName!SubForm1ControlName.Form.Dirty Then
' Save the changes to the sub form
Forms!MainFormName!SubForm1ControlName.Form.Dirty = False
End If
' Requery subform 2
Forms!MainFormName!SubForm2ControlName.Form.Requery

Exit_Save_Click:
Exit Sub

Err_Save_Click:
MsgBox Err.Description
Resume Exit_Save_Click

End Sub

Replace "MainFormName" with the name of your main form
Replace "SubForm1ControlName" with the name of the sub form CONTROL in the
main form (not the forms name - although this may be the same) for sub form
1.
Replace "SubForm2ControlName" with the name of the sub form CONTROL in the
main form (again, not the forms name) for sub form 2.
Note that I also changed your error handler code to read the correct name.

HTH,

Neil.

Chris said:
IT DOESN'T WORK !!!
HELP, PLEASE !!!
I tried and I get the error message: Microsoft Access can't find the field
'NameOfSecondSubformControl' in your expression.
Here is the code used by me:

Private Sub Save_Click()
On Error GoTo Err_Salvare_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me![Intr2-e].Form.Requery
Exit_Save_Click:
Exit Sub

Err_Save_Click:
MsgBox Err.Description
Resume Exit_Salvare_Click

End Sub

I have in a form 2 subforms:
- in the first I am entering the data (materials with quantities and
qualities)
- in the second subform you can see the data entries (introduced
using
the
first subform) and some other calculated fields (the results are
from
a
query).

Actually, after entering the data in the first subform i use a cmd. button
for saving the record, and after that, in the second subform , with another
cmd. button I refresh the data displayed (using a macro with the
Requery
and
ShowAllRecords actions ), after every record enterd from the first subform.

Is any posibillity to do these things with a single command button?
How?

Chris,

put this in the first command button's OnClick event right after the
save command:

Me![NameOfSecondSubformControl].Form.Requery

Also I'd consider making a single subform for everything, but for this
I know too few from the purpose.

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 

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