display save data on subform on another form (1 Viewer)

foxtet

Registered User.
Local time
Today, 11:00
Joined
May 21, 2011
Messages
129
Hi Guys!
I find it difficult to get data on available contacts subform when i click save button in add new contact form.

I have used a macro on click event of save button on add new contact form to do this but its not working

can you review this issue and get me a workable clue

foxtet
 

Attachments

  • Update subform record.zip
    981.7 KB · Views: 95

JHB

Have been here a while
Local time
Today, 08:00
Joined
Jun 17, 2012
Messages
7,732
Drop the macro and use Event Procedure, then the Requery in a macro is only for the active object.

If you want to requery a control that isn't on the active object, you must use the Requery method in a Visual Basic for Applications (VBA) module, not the Requery action or its corresponding Requery method of the DoCmd object. The Requery method in VBA is faster than the Requery action or the DoCmd.Requery method. In addition, when you use the Requery action or the DoCmd.Requery method, Microsoft Office Access 2007 closes the query and reloads it from the database, but when you use the Requery method, Access reruns the query without closing and reloading it. Note that the ActiveX Data Object (ADO) Requery method works the same way as the Access Requery method.
 

moke123

AWF VIP
Local time
Today, 03:00
Joined
Jan 11, 2013
Messages
3,852
not to be off topic , but i would highly recommend you re-do your tables and drop the lookup fields in your tables. you should have lookup tables and store the primary keys in a foreign key field. lookup fields mask what is really being saved in the table and cause way too many headaches going forward. google "the evils of lookup fields"

and to answer your question..

In the onclose event of your add new contact form, try...
Code:
Private Sub Form_Close()
If CurrentProject.AllForms("tbl_Entity_Info").IsLoaded = True Then
Forms![tbl_Entity_Info].Form.Requery
End If
End Sub
 
Last edited:

foxtet

Registered User.
Local time
Today, 11:00
Joined
May 21, 2011
Messages
129
That is helpful.
Now instead of refreshing whole form how do I refresh or Requery a control in a form.

In the attached sample

On AddNewContact from there is designation text box.

If designation is not available I have done to double click that text box to open add new designation form.

In this form once I add a designation & close the form the added designation should equerry in AddNew Contact form's designation combobox

This is not happening by applying the code you provided on previous post.

kindly give me a solution to requiry a control on another form instead of who form refreshing.

Thanks
foxtet
 

Attachments

  • Requiry a control on another form.zip
    973.9 KB · Views: 90

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:00
Joined
May 7, 2009
Messages
19,169
Private Sub Form_Close()
If CurrentProject.AllForms("tbl_Entity_Info").IsLoaded = True Then
Forms![tbl_Entity_Info]![tbl_Contact_Info subform].Form.Requery
End If
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:00
Joined
May 7, 2009
Messages
19,169
sorry for my previous post, here's the fix.
 

Attachments

  • Requiry a control on another form.zip
    245.3 KB · Views: 100

foxtet

Registered User.
Local time
Today, 11:00
Joined
May 21, 2011
Messages
129
Thank you arnelgp,
It helps but there is run time error 438 could you get a fix to throw this away

foxtet
 

Attachments

  • DesigAddError.PNG
    DesigAddError.PNG
    18 KB · Views: 104

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:00
Joined
May 7, 2009
Messages
19,169
can you please add a breakpoint to your code, so we may know which line has fault.
 

Users who are viewing this thread

Top Bottom