Solved

How can I continue the processing when I return to a User form in Excel VBA ?

Posted on 2013-11-11
7
277 Views
Last Modified: 2013-11-19
Hi,

I am building an Excel 2010 VBA application which will allow the user to do the following :

1. Open an Orders form and add a new record to an Orders sheet.
2. From the same Orders form, I then immediately prompt the user to create a Sales record by entering a record on a Sales form. If successful, it then returns the user back to the Orders form.
3. The user is then immediately prompted to create a Purchase record by entering a record on a Purchases form. It then returns the user back once again to the Orders form to complete the whole 3-part transaction.

However, there is a problem. When I return back from the Sales form to the Orders form the Orders form displays but it doesn't prompt the user to create a Purchase record (as in point 3.). It only displays the prompt when  I close the Orders form.

I have included a cut-down section of the code, thus far. Hopefully it is sufficiently commented that sense can be made of it.

Thanks in anticipation
Toco
Code-for-UserForm-1-to-UserForm-.txt
0
Comment
Question by:Tocogroup
  • 4
  • 3
7 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 39639084
Toco

The problem could be with the order you are showing/hiding/unloading the forms.

That's hard to tell though with only the code to look at.

Have you tried stepping through the code to see the order of execution?

Could you attach a sample workbook?

PS To unload a userform the syntax is Unload <formname> not <formname>.Unload.
0
 

Author Comment

by:Tocogroup
ID: 39639174
Hi

Yes, I stepped through the code and when I return to the Orders form after creating a Sales record (point 2 in my original post) it displays the Orders form but then waits on an event (such as closing the form) before it continues with the rest of the processing (point 3 to prompt the user to create a Purchase record).

I guess there's no way round this problem as I'm in effect calling the Orders form from within the Orders form.

Attaching a sample workbook is not possible as it contains much sensitive data and would take me an absolute age to desensitise it.

Thanks for your help though.
0
 
LVL 33

Expert Comment

by:Norie
ID: 39639258
I don't think an event is being waited for, more likely that code execution has been paused when you opened the Orders form or it has been passed to the Orders form.

As for a sample workbook, why not just remove all the data?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Tocogroup
ID: 39639289
You're possibly right about the code execution. I've found a 'get around' by adding a 'Create Sales' button on the Order form and passing Order details through to the Sales form when the Create Sales button is clicked. It serves the purpose.

As for data, there are 26 sheets and 10 forms in this application. I'm not sure it is robust enough to function without any data.

Toco
0
 
LVL 33

Expert Comment

by:Norie
ID: 39639327
Toco

Isn't this a problem with the forms not the data?
0
 

Accepted Solution

by:
Tocogroup earned 0 total points
ID: 39649056
Question cancelled. Refer to my previous post
0
 

Author Closing Comment

by:Tocogroup
ID: 39658857
As per previous post
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now