Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to refresh a Tree View from another Form

Posted on 2010-01-05
11
Medium Priority
?
848 Views
Last Modified: 2013-11-28
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
Comment
Question by:vremo
  • 6
  • 5
11 Comments
 
LVL 75
ID: 26182240
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
 

Author Comment

by:vremo
ID: 26185676
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
 
LVL 75
ID: 26185740
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
Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

 

Author Comment

by:vremo
ID: 26191108
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
 
LVL 75
ID: 26192106
"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
 

Author Comment

by:vremo
ID: 26193814
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
 
LVL 75
ID: 26193874
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
 

Author Comment

by:vremo
ID: 26193993
I checked the source of the texted field, it is coming from a table and the field is set as a long integer.  
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 26194098
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
 

Author Comment

by:vremo
ID: 26195085
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
 
LVL 75
ID: 26195568
"the other two lines are not executing but they are not mission critical.  "
Not executing ?  Meaning ?

mx
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question