• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 874
  • Last Modified:

How to refresh a Tree View from another Form

I have a feature on my form where it allows you to add additional items from a pop-up form.  When the pop-up form is closed the items are added to the appropriate table and everything executes the way it should except for one.  

I'd like to have the main form refreshed when the pop-up form is closed.  If I close the form and then came back into it, the items are there.  I tried several solutions like the Forms.Refresh option but nothing works.  The items are displayed in a Tree View format which I'm thinking might be the issue at hand.  

Any thoughts?  Thanks
0
vremo
Asked:
vremo
  • 6
  • 5
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
I assume you have a function in the main form to Load the treeview and/or refresh it?  If so, you need to Call that function from the Popup upon closing ....

mx
0
 
vremoAuthor Commented:
I tried Private, Public, and Function but non refresh the tree.  Below is the code from the form close sub.  Errors occur on the first two lines, they are nice to haves but not critical.  The last line is the one I need.  

The following is the first line in the public sub in the main form.
Public Sub fill_Tree(refreshTREE As Boolean, acode As Long)


Public Sub Form_Close()

Forms!frmMain!frmSub.cmdFinish.SetFocus
Forms!frmMain!frmSub.cmdFinish.StatusBarText = "SAVED!"
Forms!frmMain.fill_Tree True, Forms!frmMain!Code

End Sub

Open in new window

0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
In the Main form ... be sure fill_Tree is a Public Function ... then try this:

Form_frmMain.fill_Tree

As for the other two lines:

Forms!frmMain!frmSub.cmdFinish.FORM.SetFocus
Forms!frmMain!frmSub.cmdFinish.FORM.StatusBarText = "SAVED!"

mx
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
vremoAuthor Commented:
I changed the main form so fill_Tree is a Public Function.  Now it looks like this:
Public Function fill_Tree(refreshTREE As Boolean, acode As Long)

The pop-up form now has this code:
Public Sub Form_Close()

Forms!frmMain!frmSub.Form!cmdFinish.SetFocus
Forms!frmMain!frmSub.Form!cmdFinish.StatusBarText = "SAVED!"
Forms!frmMain.fill_Tree True, Forms!frmMain.Form!Code.Value


End Sub


I don't recieve any error messages but it still doesn't execute any of the 3 lines.  Again I'm most concerned with the tree refreshing, could the issue be with passing the variables to the Public Function?
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"but it still doesn't execute any of the 3 lines."
Are you saying the code in the Close event is not even firing?

And you need this syntax as I posted before - note dots instead of !

Forms!frmMain!frmSub.Form.cmdFinish.SetFocus
Forms!frmMain!frmSub.Form.cmdFinish.StatusBarText = "SAVED!"
' and you need to pass the arguments to the Tree function here
Form_frmMain.fill_Tree True, YouracodeVariableHere
                                            '  ^^^^^^^^^^^^^^^^^^^^^^^^^^   ??

mx
0
 
vremoAuthor Commented:
I made the changes but nothing is happening.  I installed an error handler in the sub and I get the following on the line where I pass the arguments to the tree function.

Error: 6 (Description: Overflow)

I thought this error was related to using integers?
Public Sub Form_Close()
On Error GoTo errorhandler

Forms!frmMain!frmSub.Form.cmdFinish.SetFocus
Forms!frmMain!frmSub.Form.cmdFinish.StatusBarText = "SAVED!"
Form_frmMain.fill_Tree True, Forms!frmMain.Form!Code.Value

errorhandler:
Call ErrorPop(Err.Number, Err.Description, Err.Source)

End Sub

Open in new window

0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Overflow means that there is an issue with the number value being passed ... due to the data type here:

Public Function fill_Tree(refreshTREE As Boolean, acode As Long)
                                                                                 ^^^^^^^^^^^^^^^

So ... something is wrong with:

Form_frmMain.fill_Tree True, Forms!frmMain.Form!Code.Value
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

maybe it's a Single or Double or ?????

mx

 
0
 
vremoAuthor Commented:
I checked the source of the texted field, it is coming from a table and the field is set as a long integer.  
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
The issue has to be with the actual value being passed.  Put a break point on

Form_frmMain.fill_Tree True, Forms!frmMain.Form!Code.Value

and see what Forms!frmMain.Form!Code.Value

In fact ... try this instead:

Form_frmMain.fill_Tree True, Forms!frmMain!Code    

mx
0
 
vremoAuthor Commented:
OK, everything was correct but by setting a break point and stepping through the code and similar code, I realized I was missing a few lines.  unreal.  The tree now refreshes, the other two lines are not executing but they are not mission critical.  
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"the other two lines are not executing but they are not mission critical.  "
Not executing ?  Meaning ?

mx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now