Userform disappears when you try to initialize from a command button

R

RPIJG

When I run the userform initialize procedure to reset the values in tex
boxes and the like instead of resetting like it should, now it close
the userform completely and then won't allow me to show it again, wha
could be the problem?




Code
-------------------
Private Sub UserForm_Initialize()
Me.MultiPage1.Value = 0
TextBox3.Value = ActiveWorkbook.Sheets("Sales Invoice").Range("G15").Value
Dim hWndForm As Long
Dim hMenu As Long
hWndForm = FindWindow("ThunderDFrame", Me.Caption) 'XL2000
hMenu = GetSystemMenu(hWndForm, 0)
DeleteMenu hMenu, SC_CLOSE, 0&
End Sub

-------------------





The Dim stuff down is to gray out the x button, there are also som
module level declarations to go with that...



Code
-------------------
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Const SC_CLOSE As Long = &HF060

-------------------





Can anyone help me out, I thought I had solved a real big problem onl
to get this, the userform shows when the workbook opens and is the
hidden when the user has finished entering values, then when the use
goes through the process of being asked to print and save, they ar
then asked if they would like to create a new record, if yes then i
shows the userform again, but the userform is still filled with all th
stuff previously entered. I tried using the unload me instead of hidin
and that wouldn't work at all, didn't give errors just didn't show th
userform either, this at least shows the userform, but now when th
user goes to clear the information by initializing the userform again
it simply closes the userform and then it can't be shown again either
Please help
 
C

Charles

RPIJG

You need to set the values of the textbox to blanks.

textbox1.value = ""

Also you need to set the checkbox or optionbottons to false

userform1.optionbutton1 = False
userform1.checkbox1 = False


This should clear the previous input.

HTH

Charle
 
R

RPIJG

Hi Charles, The values for the textboxes are set that way (I shortene
the code considerably because there was alot of it) but the textboxe
get their values from the Worksheet as I showed above, but when th
code runs the spaces are empty so the textboxes should be empty.
However, this would only be so if I could get the userform t
initialize, but when I do that, it disappears and then I am not able t
show it again unless I close the template and reopen it. Why would
userform initialize cause the userform to be unload or hidden so tha
it couldn't be shown
 
R

RPIJG

Charles I tried it...still nothing, the userform doesn't show, but
don't have any errors, it simply doesn't show
 
C

Charles

RPIJG

If you want send me your workbook and I'll look at it. However I canno
look at it today. Other things I have to do right now.


Charle
 
R

RPIJG

Sure Charles I'll send you an email with this...as well as some othe
instructions (mainly because it will fault without a few folder name
and what not). I truly appreciate this, you so far are the only perso
who has been willing to take a look at this at all. Thanks
 
R

RPIJG

my file is too big to be attached here, I thought I'd attach it but i
won't, so I've gone ahead and put it up here, hopefully you ca
download it from here...a few things to mention, all the files an
folders in the .zip need to be put into a folder called SyntheticShiel
in the C:\ drive so that you have C:\SyntheticShield as the prior, tha
way you get C:\SyntheticShield\Quotes as a folder location as well a
some other references (ie saving etc.) The template I'm havin
problems with is the SyntheticShieldInvoiceMaker template, th
QuoteMaker template works without a problem. Anyone with any comment
or criticisms feel free, I started out doing this as a major rookie
and slowly made things way more complicated for me (hopefully easie
for the user). Thanks Charles for you help, and anyone else tha
chooses to chime in :)

http://home.ripway.com/2004-1/53847/InvoiceMaker.zi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top