Need subform to update prior to exiting

jadefury

Registered User.
Local time
Today, 02:48
Joined
Jan 4, 2010
Messages
21
I have a main form and sub form. The subform is linked to a query as the information pertains to an employee id. I need the subform to update as soon as the main form record is saved. I have a button that saves the information. Where and how do I get the subform to immediately display the information without exiting the record and going back into it?


Thanks!
 
I don't know hardly anything about VBA programming I just want a button that will requery my first and second subforms while still in the main form. Can you give me any additional assistance. Thanks!
 
You have two SubForms on your MainForm? What are the names of the SubFormControls that display these SubForms?
 
subform 1 is called "subcaredb1"

subform 2 is called "dep2"
 
I hope I answered that question correctly, but both subforms are linked by customer id not for sure what else you are looking for.

Thanks!
 
Are the SubFormControls named the same as the Forms they display?
 
How do I find that out? Sorry I have been playing around in access for awhile and I am only using the subforms as subforms I did not rename them when I added them as a sub form. I hope that answers the question
 
You know you are looking at the SubFormControl when the data tab of the property sheet shows the LinkMaster/ChildFields properties. The name of the control is on the Other tab.
 
Yes they are named the same subcaredb1 for subform1 and dep2 for subform2
 
So your mainForm Save button will look like:
Code:
If Me.Dirty Then Me.Dirty = False
subcaredb1.Form.subcaredb1.Requery
dep2.Form.dep2.Requery
 
okay getting an error "application-defined or object-defined error" I added the code into the save record button. The code as it stands currently is as follows:

Private Sub Command107_Click()
On Error GoTo Err_Command107_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

If Me.Dirty Then Me.Dirty = False
subcaredb1.Form.subcaredb1.Requery
dep2.Form.dep2.Requery
Exit_Command107_Click:
Exit Sub
Err_Command107_Click:
MsgBox Err.Description
Resume Exit_Command107_Click

End Sub
 
Try:

Code:
Private Sub Command107_Click()
   On Error GoTo Err_Command107_Click
[COLOR="Red"]
'   DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70[/COLOR]

   If Me.Dirty Then Me.Dirty = False
   [COLOR="Red"]Me[/COLOR].subcaredb1.Form.subcaredb1.Requery
   [COLOR="Red"]Me[/COLOR].dep2.Form.dep2.Requery
   
Exit_Command107_Click:
   Exit Sub
   
Err_Command107_Click:
   MsgBox Err.Description
   Resume Exit_Command107_Click

End Sub
 
still getting a run-time error '2465':

application-defined or object-defined error

Thanks again you have been a big help
 
D'oh...<<slapping forehead>>
Code:
Private Sub Command107_Click()
   On Error GoTo Err_Command107_Click

'   DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

   If Me.Dirty Then Me.Dirty = False
   [COLOR="Red"]Me.subcaredb1.Form.Requery
   Me.dep2.Form.Requery[/COLOR]
   
Exit_Command107_Click:
   Exit Sub
   
Err_Command107_Click:
   MsgBox Err.Description
   Resume Exit_Command107_Click

End Sub
 
Wow that worked you are a hero today! Thank you so much!
 
That's great! It does look like my <<AIR CODE>> skills need a bit of honing though, sorry.
 

Users who are viewing this thread

Back
Top Bottom