Solved

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

Posted on 2013-11-11
7
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Search data on excel sheet 11 38
Converting time 4 37
Color a cell based on a date in Excel 8 22
any combination of this numbers 9 31
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

756 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