I have an Excel userform with a Part Number textbox that users enter data to, (a SQL db search uses this data to return a query) .
The form works just fine when users do not switch from the workbook that contains the form (MORF.xls) to another workbook.
Problem happens when they open the form, then switch to another workbook (to copy/paste their Part Number), then paste the data to the form. The Activeworkbook is no longer MORF.xls, thus all my workbook references (eg; Set SelectedSites_AllChk = Range("E7")) refer to the other workbook which is active.
What I need is a method to publicly declare the name of the MORF.XLS workbook, and make this available to the code in the userform.
Note that I have a Sub in a Module (Sub ShowForm()) which shows the form, then a button on the form which runs the SQL query.
I believe I need to be able to assign the workbook name in the ShowForm Sub, then pass this to a workbook variable in the userform.
Thanks a lot,