Calander function and login problem (1 Viewer)

tom1252

Registered User.
Local time
Today, 07:10
Joined
Sep 18, 2009
Messages
96
0000 - sorry
 

Funkyaccess

Registered User.
Local time
Yesterday, 23:10
Joined
Oct 8, 2009
Messages
69
I think I've spotted the error. Its to do with name conventions.

it difficult to see what ServerID is if ServerID is a global variable/table column and textfield. So if we name the variable to gblServerID then where ever you see that name you will know its refering to the global variable.

Having a look at your login form why is it based on a table? i.e it fetches data from the table and places it on the form. or is it just for a demo?
 

tom1252

Registered User.
Local time
Today, 07:10
Joined
Sep 18, 2009
Messages
96
Just a demo and so i have to change in the module the ServerID to gblServerID
 

Funkyaccess

Registered User.
Local time
Yesterday, 23:10
Joined
Oct 8, 2009
Messages
69
Sorry my fault as well its not controlsource but DefaultValue.

Now login to the attached DB. click on "Transaction" and the ServerID should be set.

What I did to get this to work?

first I change the global variable to gblServerID

Then with the login form's code I did the following:

Code:
Private Sub Command9_Click()
'Used as a where clause
    Dim lSearch As String
'Build the criteria to limit the row where servername and passcode match
    lSearch = "[ServerName]='" & Me.txtServerName & "' AND [Passcode] = '" & Me.txtPasscode & "'"
'check user should be able to access system
    If Me.ServerName = Me.txtServerName And Me.Passcode = Me.txtPasscode Then
' Using DLookup we find the ServerID in tblServer and meets the where/criteria clause
' We then set the global variable gblServerID
        gblServerID = DLookup("[ServerID]", "tblServer", l_search)
'Close login form
        DoCmd.Close
'Open Main Form
        DoCmd.OpenForm "frmMainMenu"
    Else
'Inform the user they have not been successful
        MsgBox "Password incorrect or required"
    End If
End Sub

I then added a button on the main form to navigate to the transaction form.

On the transaction form I change the on load code to the following
Code:
Private Sub Form_Load()
' Only change the default value if the gblServerID is set and not 0
    If (IsNull(gblServerID) = False And gblServerID > 0) Then
'Change the default value to the global variables values
        Me.txtServerID.DefaultValue = gblServerID
    End If
End Sub

Hopefully this helps you. If it does please add some rep points for me.
 

Attachments

  • Login.zip
    233.5 KB · Views: 86
Last edited:

tom1252

Registered User.
Local time
Today, 07:10
Joined
Sep 18, 2009
Messages
96
yeah- sorry didnt get back sooner and i added rep!!
 

Users who are viewing this thread

Top Bottom