im stuck

undergrad

Registered User.
Local time
Today, 05:49
Joined
May 29, 2003
Messages
25
below is code i have written to use for a simple password action. all im trying to get is: enter a password and either make it into the next screen or not.

im not used to codeing in VB, and i think i may be trying to simulate a subroutine the way i would do it in fortran. trouble here is i really have no idea how to set it up in VB

i have spent too much time searching this forum for my answer so i decided to make a post...my first :)

Option Compare Database
'sets variable to check password access
Const pass As String = gigem

Private Sub secure_Enter()
Public check As Integer
'Check value is checked on doorway form entering into secured form. If it is 1 it is allowed to continue. If it is 2 it remains on the doorway form '
check = 2
If txtsecure = pass Then
check = 1
DoCmd.Close
Else
check = 2
DoCmd.Close
End If
End Sub

if you think there is a link for me that would work fine. or maybe just let me know what is the major problem here is and i can go from there.

thanks alot!
undergrad
 
It's a good idea to write code with the Option Explicit statement right below Option Compare Database. If you did, you'd see that this statement: Const pass As String = gigem is probably causing your program some problems.

I'm not sure what you're trying to do there, but your comment indicates that you want to set up a variable. The Const word, however, sets up a constant value. Here, you've set it equal to gigem. If you were trying to set pass equal to the string "gigem" then you need to enclose it in quotes. Otherwise, Access will think you're trying to set pass equal to a variable named gigem.
 
thank you for your quick reply

that solved that problem

unfortunatley i think i have more difficulties than i thought and not many human resorces. i am really just learning to code in VB does anyone know of a good VB tutorial site?

thanks again!
 
I can't recommend a web site as much as I can suggest a couple of books. I have these and loan them out to coworkers who are working on small projects and just want to get a better handle on Access and they really are great for explaining simple vb/vba syntax and applying them to Access Objects and controls.

Your going to laugh :D but I really do recommend them:

Access 97 Programming for Dummies

Access 2000 Programming for Dummies

enjoy :)
 
no way those books for dummies are awesome. i read the access 97 for dummies as an intern my freshman year. they work like a charm. maybe i can get one of those programming ones for cheap on line.

thanks !
 
Not sure if this will help or not, it's in a vb project I did last year for an application. Maybe you can sort through it and get an idea or two.

I have tables that contain the employee (Author) and their password. The app opens the db and than so on....

The form is basic, a txtUserName and txtPassword control and a cmdOK button.

I've found, through frustration and such, that a VB class helped alot.



Option Explicit
Public LoginSucceeded As Boolean

Private Sub cmdCancel_Click()
If LoginSucceeded = False Then
Unload Me
End If

End Sub

Private Sub cmdOK_Click()

If SignIn(txtPassword) = True Then
Unload Me
frmExceptionNotices.fraControls.Enabled = True
Else
Me.txtPassword.Text = vbNullString
Me.txtUserName.Text = vbNullString
Me.txtUserName.SetFocus
End If

End Sub

Public Function SignIn(txtPassword) As Boolean

Dim Venice As Database
Dim Authorized As Recordset

Set Venice = OpenDatabase("G:\Facilities\Development\Venice.mdb")
Set Authorized = Venice.OpenRecordset("Select * from Author")

Dim pstrUser As String
pstrUser = txtUserName

If pstrUser <> vbNullString Then
Authorized.FindFirst "Employee = '" & pstrUser & "'"
If Authorized.NoMatch = True Then
MsgBox "UserID Unknown or Incorrect! ", vbCritical, "Login Error"
SignIn = False
ElseIf Authorized.Fields("Password") = Me.txtPassword And Authorized.Fields("Level") = "manager" Then
SignIn = True
Else
SignIn = False
MsgBox "Invalid Password or Access Level", vbCritical, "Login Error"
End If
End If

End Function

Private Sub Form_Unload(Cancel As Integer)

Set frmLoginMetrics = Nothing

End Sub
 

Users who are viewing this thread

Back
Top Bottom