PDA

View Full Version : sign in help



ashgull80
02-17-2008, 11:33 AM
hi
in the workbook example i have provided i have a userform that opens when the workbook is opened, it is for signing in to the workbook.
but i wish to have the sign in form on the workbook, not in a userform.
the example shows what i wish to do i just need help achieving it.
thanks ash

Bob Phillips
02-17-2008, 11:48 AM
.

ashgull80
02-17-2008, 12:01 PM
thank you thats great, what code will i need for when the correct password is submitted it searches for a workbook in mydoc with the same name as the username and then opens that book?
thank you
sorry bout my many posts at mo but on hol and just connected to the internet for a short while.

Bob Phillips
02-17-2008, 12:03 PM
Isn't it just

Workbooks.Open cboName.Value

ashgull80
02-17-2008, 01:16 PM
thanks that works great apart from one prob,
i have moved the ode into a new workbook and now i get a vba error msg,
"Method 'Range' of object '_Application' Failed

what does this mean?
thanks ash

Bob Phillips
02-17-2008, 01:56 PM
Where does this happen?

ashgull80
02-17-2008, 02:11 PM
i just copied the code into a new boox but more complex i think everything is the same but when i try to sign in it comes up with that error and when debugging it highlights ;
sPassword = Application.Index(Application.Range("_passwords"),_
Application.match(Me.cboUsername.Value, Application.Rang ("_names"),0)

Bob Phillips
02-17-2008, 02:52 PM
Post the workbook.

ashgull80
02-17-2008, 04:26 PM
here you go
username - admin
password - a
thanks

ashgull80
02-18-2008, 06:53 AM
any ideas

Bob Phillips
02-18-2008, 07:08 AM
Easy tiger, this may be your job, it's not ours.



Private Sub cmdSignIn_Click()
Static nCount As Long
Dim i As Long
Dim sPassword As String
Dim sh As Worksheet
nCount = nCount + 1
If nCount > 5 Then ThisWorkbook.Close
sPassword = Application.Index(wsPasswords.Range("Passwords"), _
Application.Match(Me.cboUsername.Value, wsPasswords.Range("Names"), 0))
If sPassword <> Me.txtPassword.Text Then

MsgBox "Invalid password"
Me.txtPassword.SelStart = 0
Me.txtPassword.SelLength = Len(Me.txtPassword.Text)
Else
Workbooks.Open cboUsername.Value
End If
End Sub

ashgull80
02-18-2008, 07:37 AM
sorry just got no internet after 4pm 2day. thanks very much for all your help!

Bob Phillips
02-18-2008, 07:48 AM
Why is that?

ashgull80
02-18-2008, 07:55 AM
on holiday in barbados but got burnt so spent last day indoors playing but gotta get back out 2 view the island at 12, (4pm uk)

Bob Phillips
02-18-2008, 07:59 AM
Excuse me ... holiday ... working - is your brain a bit fried by that sun?

ashgull80
02-18-2008, 08:03 AM
well the prob is i got so bored sat in the appartment whilst every1 else was sunbathing and so i got out the laptop and then just thought id have a little play, and here i am sat in the appartment on the internet, hehe but like i said got to get back out into the sun 2day.