I have a userform called "ProductDBForm" that uses a multipage to provide detailed data on all products in our range. I use a "Homepage" of sorts with a few images and a transparent box over each with a macro assigned to launch the relevant form or function. One of these is used to launch the "Product Database" using the following code:
The code has worked flawlessly since I added it until yesterday when, for reasons I'm yet to understand, it started crashing Excel when run via the homepage click. However it only crashed Excel if clicking the image that runs this macros is the first thing a user does when opening the workbook.
I can still launch the form the following ways:
1. If I enter the VBA editor and open the userform edit page, I can display it perfectly by hitting the F5 key
2. If I enter the VBA editor and run the "launchProdDB" code, it displays the form perfectly
3. If I run another piece of code before running the "launchProdDB" code, I can then run the "launchProdDB" code and it works perfectly
Once any of the above are done, I can then click the image on my "homepage" to run the "launchProdDB" code above without any issues.
The code only crashes if it is the very first thing a user does when opening the workbook. I know that all the code works because I can run it without making any changes to it as long as it isn't the first thing I do.
Does anyone have any suggestions or ideas on what might be causing this all of a sudden, and why it works fine the rest of the time?
VBA Code:
Sub launchProdDB()
If UserCheck(12) = "NO" Then
MsgBox "Sorry, you do not have the required permissions to access this function.", vbCritical + vbOKOnly, "Access Denied"
Call saveLog("PrDB Access Denied.", "User attempted to launc the product database; permissions not found")
Exit Sub
End If
Sheets("ProductDB").Visible = True
Sheets("ProductDB").Select
With ProductDBForm
.StartUpPosition = 1
.Show vbModeless
End With
Call saveLog("Open PrDB", "User successfully launched product database")
End Sub
The code has worked flawlessly since I added it until yesterday when, for reasons I'm yet to understand, it started crashing Excel when run via the homepage click. However it only crashed Excel if clicking the image that runs this macros is the first thing a user does when opening the workbook.
I can still launch the form the following ways:
1. If I enter the VBA editor and open the userform edit page, I can display it perfectly by hitting the F5 key
2. If I enter the VBA editor and run the "launchProdDB" code, it displays the form perfectly
3. If I run another piece of code before running the "launchProdDB" code, I can then run the "launchProdDB" code and it works perfectly
Once any of the above are done, I can then click the image on my "homepage" to run the "launchProdDB" code above without any issues.
The code only crashes if it is the very first thing a user does when opening the workbook. I know that all the code works because I can run it without making any changes to it as long as it isn't the first thing I do.
Does anyone have any suggestions or ideas on what might be causing this all of a sudden, and why it works fine the rest of the time?