Solved

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

Posted on 2013-11-11
7
279 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

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 article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

809 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