Message - Too many continuation lines
am 13.04.2008 12:44:00 von Khartoum
Know somebody out there will laugh a this but i have the following function
that opens a certain form based on the password but because there are so many
forms, i am getting the 'too many continuation lines' message. How can i
rewrite the else if code to overcome this:
Private Sub okbutton_Click()
If Forms![password form].text_password = "atay1" Then DoCmd.OpenForm "Angela
Taylor" _
Else: If Forms![password form].text_password = "dgra15" Then DoCmd.OpenForm
"Dave Graham" _
Else: If Forms![password form].text_password = "fles16" Then DoCmd.OpenForm
"Fred Lester" _
Else: MsgBox "You have entered an incorrect password", vbOKCancel
DoCmd.Close acForm, "password form", acSaveNo
End Sub
(There are another 20+ lines attached to this)
Thanks John
Re: Message - Too many continuation lines
am 13.04.2008 15:30:29 von Jeroen Mostert
Khartoum wrote:
> Know somebody out there will laugh a this
No, it's not particularly funny. It makes me sad.
> but i have the following function that opens a certain form based on the
> password but because there are so many forms, i am getting the 'too many
> continuation lines' message. How can i rewrite the else if code to
> overcome this:
>
Use the ElseIf statement and remove the colons and the underscores. There's
no need to squeeze everything on one line. So instead of this:
> Private Sub okbutton_Click()
> If Forms![password form].text_password = "atay1" Then DoCmd.OpenForm "Angela
> Taylor" _
> Else: If Forms![password form].text_password = "dgra15" Then DoCmd.OpenForm
> "Dave Graham" _
Write this:
If Forms![password form].text_password = "atay1" Then
DoCmd.OpenForm "Angela Taylor"
ElseIf Forms![password form].text_password = "dgra15" Then
DoCmd.OpenForm "Dave Graham"
Since you're checking a single expression, you could use a Select...Case
statement and write this:
Select Forms![password form].text_password
Case "atay1"
DoCmd.OpenForm "Angela Taylor"
Case "dgra15"
DoCmd.OpenForm "Dave Graham"
But actually, don't write that either. Why aren't you storing the passwords
as hashes in a database? This is completely unmaintainable -- every time the
user base changes the code has to change. It's also fairly trivial for
someone to open up your application in Notepad and extract all the
passwords. You don't have to be a master hacker for that.
And if these are the *actual* passwords you're using, you might as well not
bother with passwords at all and have people select their account from a
drop-down list, because they're trivial to guess. This is just pretend-security.
You may want to take a look at the integrated security options for Windows.
This will allow users to use the application without needing a separate
login, as they can just use their Windows account. Take a look at the
Environment.UserName property.
--
J.
http://symbolsprose.blogspot.com