View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RPIJG[_60_] RPIJG[_60_] is offline
external usenet poster
 
Posts: 1
Default Userform disappears when you try to initialize from a command button

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

--
Message posted from http://www.ExcelForum.com