Solved

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

Posted on 2013-11-11
7
278 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

948 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

22 Experts available now in Live!

Get 1:1 Help Now