Message - Too many continuation lines

K

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
 
J

Jeroen Mostert

Khartoum said:
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.
 

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

Similar Threads

Code 5
runtime error 3
recordset issue 5
Users log 4
Open Form Code 1
Popup form 3
Case select 1
translation needed 1

Top