How do you refresh/requery a different for than you are working on

I

Iram

I have a "data entry" form and when i am done adding a new record I want to
click on a close button that not only closes the form but also refreshes
another form that is open.

I know of the "Me.Requery" but that only requeries the form that you are on.
I need to refresh a different form.

Can you help me with the correct vba for this?

Iram/mcp
 
N

NKTower

in an appropriate location, such as the data entry form's OnClose event, try
this...


Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("theOtherForm").IsLoaded Then
DoCmd.OpenForm "theOtherForm"
End If
SET ftm_theOtherForm = Forms![theOtherForm].Form
frm_theOtherForm.Requery
SET frm_theOtherForm = Nothing
 
I

Iram

Since I am not too familiar with how to add my other forms name to your code,
can you help he put it in your code? The other forms name is frm_ActiveTasks
This is the name of the form that needs to be requeried. And yes I do plan
on putting your code on the On Click of the exit button on the data entry
form.


Thanks.
Iram



NKTower said:
in an appropriate location, such as the data entry form's OnClose event, try
this...


Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("theOtherForm").IsLoaded Then
DoCmd.OpenForm "theOtherForm"
End If
SET ftm_theOtherForm = Forms![theOtherForm].Form
frm_theOtherForm.Requery
SET frm_theOtherForm = Nothing



Iram said:
I have a "data entry" form and when i am done adding a new record I want to
click on a close button that not only closes the form but also refreshes
another form that is open.

I know of the "Me.Requery" but that only requeries the form that you are on.
I need to refresh a different form.

Can you help me with the correct vba for this?

Iram/mcp
 
N

NKTower

Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("frm_ActiveTasks").IsLoaded Then
DoCmd.OpenForm "frm_ActiveTasks"
End If
SET ftm_theOtherForm = Forms![frm_ActiveTasks].Form
frm_theOtherForm.Requery
SET frm_theOtherForm = Nothing

Iram said:
Since I am not too familiar with how to add my other forms name to your code,
can you help he put it in your code? The other forms name is frm_ActiveTasks
This is the name of the form that needs to be requeried. And yes I do plan
on putting your code on the On Click of the exit button on the data entry
form.


Thanks.
Iram



NKTower said:
in an appropriate location, such as the data entry form's OnClose event, try
this...


Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("theOtherForm").IsLoaded Then
DoCmd.OpenForm "theOtherForm"
End If
SET ftm_theOtherForm = Forms![theOtherForm].Form
frm_theOtherForm.Requery
SET frm_theOtherForm = Nothing



Iram said:
I have a "data entry" form and when i am done adding a new record I want to
click on a close button that not only closes the form but also refreshes
another form that is open.

I know of the "Me.Requery" but that only requeries the form that you are on.
I need to refresh a different form.

Can you help me with the correct vba for this?

Iram/mcp
 
I

Iram

I get a yellow highlight over...
If Not Current.Project.AllForms("frm_ActiveTasks").IsLoaded Then

By the way on the On Click of the exit button I had some other code to make
sure that the required fields were entered and then I added your code
altogether it looks like this...

Private Sub CloseAndSaveData_Click()
If Me.Dirty Then
Me.Dirty = False
End If
DoCmd.Close acForm, Me.Name

Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("frm_ActiveTasks").IsLoaded Then
DoCmd.OpenForm "frm_ActiveTasks"
End If
Set ftm_theOtherForm = Forms![frm_ActiveTasks].Form
frm_theOtherForm.Requery
Set frm_theOtherForm = Nothing

End Sub






Iram/mcp






NKTower said:
Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("frm_ActiveTasks").IsLoaded Then
DoCmd.OpenForm "frm_ActiveTasks"
End If
SET ftm_theOtherForm = Forms![frm_ActiveTasks].Form
frm_theOtherForm.Requery
SET frm_theOtherForm = Nothing

Iram said:
Since I am not too familiar with how to add my other forms name to your code,
can you help he put it in your code? The other forms name is frm_ActiveTasks
This is the name of the form that needs to be requeried. And yes I do plan
on putting your code on the On Click of the exit button on the data entry
form.


Thanks.
Iram



NKTower said:
in an appropriate location, such as the data entry form's OnClose event, try
this...


Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("theOtherForm").IsLoaded Then
DoCmd.OpenForm "theOtherForm"
End If
SET ftm_theOtherForm = Forms![theOtherForm].Form
frm_theOtherForm.Requery
SET frm_theOtherForm = Nothing



:

I have a "data entry" form and when i am done adding a new record I want to
click on a close button that not only closes the form but also refreshes
another form that is open.

I know of the "Me.Requery" but that only requeries the form that you are on.
I need to refresh a different form.

Can you help me with the correct vba for this?

Iram/mcp
 
N

NKTower

a) Move the
DoCmd.Close acForm, Me.Name
to after my code.

b) Do I see a "dot" between Current and Project? Shouldn't be there!

c) What version of Access are you running? I'm not sure, but I don't think
that CurrentProject.AllForms(formname).IsLoaded is available in Access 2000
or earlier. But there IS a similar function available, it's in the Northwind
demo database for those earlier versions, or do a search on Google for
IsLoaded.

Iram said:
I get a yellow highlight over...
If Not Current.Project.AllForms("frm_ActiveTasks").IsLoaded Then

By the way on the On Click of the exit button I had some other code to make
sure that the required fields were entered and then I added your code
altogether it looks like this...

Private Sub CloseAndSaveData_Click()
If Me.Dirty Then
Me.Dirty = False
End If
DoCmd.Close acForm, Me.Name

Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("frm_ActiveTasks").IsLoaded Then
DoCmd.OpenForm "frm_ActiveTasks"
End If
Set ftm_theOtherForm = Forms![frm_ActiveTasks].Form
frm_theOtherForm.Requery
Set frm_theOtherForm = Nothing

End Sub






Iram/mcp






NKTower said:
Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("frm_ActiveTasks").IsLoaded Then
DoCmd.OpenForm "frm_ActiveTasks"
End If
SET ftm_theOtherForm = Forms![frm_ActiveTasks].Form
frm_theOtherForm.Requery
SET frm_theOtherForm = Nothing

Iram said:
Since I am not too familiar with how to add my other forms name to your code,
can you help he put it in your code? The other forms name is frm_ActiveTasks
This is the name of the form that needs to be requeried. And yes I do plan
on putting your code on the On Click of the exit button on the data entry
form.


Thanks.
Iram



:

in an appropriate location, such as the data entry form's OnClose event, try
this...


Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("theOtherForm").IsLoaded Then
DoCmd.OpenForm "theOtherForm"
End If
SET ftm_theOtherForm = Forms![theOtherForm].Form
frm_theOtherForm.Requery
SET frm_theOtherForm = Nothing



:

I have a "data entry" form and when i am done adding a new record I want to
click on a close button that not only closes the form but also refreshes
another form that is open.

I know of the "Me.Requery" but that only requeries the form that you are on.
I need to refresh a different form.

Can you help me with the correct vba for this?

Iram/mcp
 
I

Iram

Your the man it worked!
I made the changes as you said and it works swell.
I am using Access 2003.

Thanks a lot.

Iram/mcp



NKTower said:
a) Move the
DoCmd.Close acForm, Me.Name
to after my code.

b) Do I see a "dot" between Current and Project? Shouldn't be there!

c) What version of Access are you running? I'm not sure, but I don't think
that CurrentProject.AllForms(formname).IsLoaded is available in Access 2000
or earlier. But there IS a similar function available, it's in the Northwind
demo database for those earlier versions, or do a search on Google for
IsLoaded.

Iram said:
I get a yellow highlight over...
If Not Current.Project.AllForms("frm_ActiveTasks").IsLoaded Then

By the way on the On Click of the exit button I had some other code to make
sure that the required fields were entered and then I added your code
altogether it looks like this...

Private Sub CloseAndSaveData_Click()
If Me.Dirty Then
Me.Dirty = False
End If
DoCmd.Close acForm, Me.Name

Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("frm_ActiveTasks").IsLoaded Then
DoCmd.OpenForm "frm_ActiveTasks"
End If
Set ftm_theOtherForm = Forms![frm_ActiveTasks].Form
frm_theOtherForm.Requery
Set frm_theOtherForm = Nothing

End Sub






Iram/mcp






NKTower said:
Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("frm_ActiveTasks").IsLoaded Then
DoCmd.OpenForm "frm_ActiveTasks"
End If
SET ftm_theOtherForm = Forms![frm_ActiveTasks].Form
frm_theOtherForm.Requery
SET frm_theOtherForm = Nothing

:

Since I am not too familiar with how to add my other forms name to your code,
can you help he put it in your code? The other forms name is frm_ActiveTasks
This is the name of the form that needs to be requeried. And yes I do plan
on putting your code on the On Click of the exit button on the data entry
form.


Thanks.
Iram



:

in an appropriate location, such as the data entry form's OnClose event, try
this...


Dim frm_theOtherForm As Form

' make sure the other form is open
If Not Current.Project.AllForms("theOtherForm").IsLoaded Then
DoCmd.OpenForm "theOtherForm"
End If
SET ftm_theOtherForm = Forms![theOtherForm].Form
frm_theOtherForm.Requery
SET frm_theOtherForm = Nothing



:

I have a "data entry" form and when i am done adding a new record I want to
click on a close button that not only closes the form but also refreshes
another form that is open.

I know of the "Me.Requery" but that only requeries the form that you are on.
I need to refresh a different form.

Can you help me with the correct vba for this?

Iram/mcp
 

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