PDA

View Full Version : Solved: UserForm Help needed



Emoncada
02-08-2008, 08:49 AM
I have this code in the form that giving me problems.

Public FilePath As String
Private Sub CmdDefault_Enter()
Call CmdSignOff_Click
End Sub

Private Sub CmdGoBack_Click()
Unload FrmSignatureConfirm
End Sub

Private Sub CmdSignOff_Click()

Dim res As String, res2 As String, ns As String
res = TxtPassword.Value

ActiveSheet.Unprotect "kimberly"
If ButtonNS.Value = True Then
res2 = "Pochontas1"

ns = "Nick Smith"

End If

If ButtonMJ.Value = True Then
res2 = "CORAL100"

ns = "Martin Jones"

End If
If ButtonES.Value = True Then
res2 = "kimbo04"

ns = "Eddie Santos"

End If
If res = res2 Then
Sheets("Incoming").LblSignConfirm.Caption = ns

FrmGroup.Show

'------------------------------Saving In Incoming Confirmations---------------------
Dim fp As String, strSaveIncoming As String

FilePath = ""
'fp = "C:\Depot Incoming\Incoming Confirmations\"
fp = "S:\Depot Incoming\Incoming Confirmations\"
Call MakeFolders(fp)
Call MakeFolders(Range("K2").Value & "\")
Call MakeFolders(Format(Date, "yyyy") & "\")
Call MakeFolders(Format(Date, "mmm") & "\")


Application.DisplayAlerts = False
strSaveIncoming = Format(Range("I1").Value, "mmddyy") + " Incoming Sheet" + ".xls"
Application.DisplayAlerts = True

ActiveWorkbook.SaveAs FilePath & strSaveIncoming, xlWorkbookNormal
FilePath = ""
'----------------------------Finishing Saving File----------------------------------
ActiveSheet.Protect "kimberly"
Unload FrmSignatureConfirm
End If
If res = "" Then
MsgBox ("Please Enter A Password")
Me.TxtPassword.SetFocus
Else
If res <> res2 Then
If MsgBox("Please Check User Name and Password!", vbOKCancel, "Password Error!") = vbOK Then
FrmSignatureConfirm.ButtonES.SetFocus
SendKeys "{Tab}+"

Exit Sub

Else
Unload FrmSignatureConfirm

End If
End If
End If
ActiveSheet.Protect "kimberly"
End Sub
Private Sub MakeFolders(fp As String)
FilePath = FilePath & fp
If Dir(FilePath, vbDirectory) = "" Then MkDir FilePath
End Sub

This is a form with names and the person needs to select his/her name and then enter there password. If res = res2 then it should open FrmGroup then save.

This is the FrmGroup Code

Private Sub CmdGo_Click()

If FrmGroup.ButtonDepot.Value = True Then Sheets("Incoming").Range("K2").Value = FrmGroup.ButtonDepot.Caption
If FrmGroup.ButtonMortgage.Value = True Then Sheets("Incoming").Range("K2").Value = FrmGroup.ButtonMortgage.Caption
If FrmGroup.ButtonPcar.Value = True Then Sheets("Incoming").Range("K2").Value = FrmGroup.ButtonPcar.Caption
Unload FrmGroup
End Sub

Basically this form should come up when the Go button is clicked on FrmSignatureConfirm. What is happening is the FrmSignatureConfirm doesn't even come up it goes straight to FrmGroup. Any help would be great.

rory
02-08-2008, 09:37 AM
Is your CmdDefault button, the first in the tab order? Youa re using its Enter event to run the signoff code rather than its Click event - is that deliberate?

Emoncada
02-08-2008, 12:15 PM
rory thanks a ton I had the CmdDefault as 1 in the tab order. That seems to have been the problem.