I am just about done my Price Analyzer, but I keep running into Run-Time and other errors when I click the "x" button when the forms comes up and when I click cancel.
All I need to to be able to click "x" and have it not bring up and error and when the cancel button is clicked that the macro stops (so it doesn't do anything).
I have attached a .txt file with the 3 needed scripts (module 1, Button_Cancel, and Button_Ok)
Thread moved to the 'Office Development/VBA' forum... note that while it certainly isn't made clear, the "VB Editor" in Office programs is actually VBA rather than VB, so the 'VB6' forum is not really apt
After your line which shows the form, you pull data from the form fields. If the cancel button is clicked, you are exiting the form (instead of hiding it), so it is no longer available for the following lines (which is why you are getting an error - the fields no longer exist). You'd probably be better setting a boolean variable in the form when the user clicks OK, and checking that variable before continuing. If the variable is true, you can continue your priceanalyzer sub. If it's false then exit the sub. And you need to hide the form from both buttons, only close the form from your priceAnalyzer sub.