Calander function and login problem (1 Viewer)

tom1252

Registered User.
Local time
Today, 23:52
Joined
Sep 18, 2009
Messages
96
Hi

I have a form which has i textbox called date and i wondered if there is a way of getting it to put the date of that day to be put in automaticlly.

For my login form i have the code below

Private Sub Command9_Click()

If Me.ServerName = Me.txtServerName And Me.Passcode = Me.txtPasscode Then

DoCmd.Close
DoCmd.OpenForm "frmMainMenu"

Else
MsgBox "Password incorrect or required"

End If

End Sub


How can i get it to stay logged in and remember which account it is logged in to?


Thanks
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 08:52
Joined
Jan 20, 2009
Messages
12,854
The date is done with a control source:
= Date() (That means today)

Set the Account as a Global variable.
This is done by first declaring it as a Public variable in a Standard Module (not the form's module). Declare it in the declarations section at the top.

Then use the following style of statement anywhere in the VBA:
MyPublicVariable = whatever
and the variable will be that value in everywhere in the project.
 

tom1252

Registered User.
Local time
Today, 23:52
Joined
Sep 18, 2009
Messages
96
cheers the date worked.

Do i create a module from scratch?

And

What do i declare it as?

Cheers
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 08:52
Joined
Jan 20, 2009
Messages
12,854
It can be declared in any of the Standard Modules you already have.
It is a matter of taste but I like having one module with just the Global variables declared.

What you declare it as depends on how you use it. I have a numeric key on my Users table (which also includes their domain login name and real name).

The declaration syntax for mine would be:
Public VariableName As Integer
 

tom1252

Registered User.
Local time
Today, 23:52
Joined
Sep 18, 2009
Messages
96
I have used the following

Public ServerID As Integer

How can i check it works?

Also for one of my forms it ask you to put it your serverId now it remebers serverID how can i get it to go in automaticlly
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 08:52
Joined
Jan 20, 2009
Messages
12,854
In your forms's module declaration section include Option Explicit.
This means all variables must be explicitly declared. (It is a good practice to do this always.)
This command will set it:
ServerID = 1
If it isn't defiined Access will complain when you run the command.
Then you should be able to refer to it in any module and get that value.

What is ServerID? Is it related to user's login name?
Usename can be returned from this function:
Environ(username)
 

tom1252

Registered User.
Local time
Today, 23:52
Joined
Sep 18, 2009
Messages
96
In The server table

ServerID
ServerName
Passcode

ServerID is a primary key and link to SeverId in the sales table but the rest are not linked to any other tables.

The module i created was from scratch and is not linked to any of the forms
 

Zaeed

Registered Annoyance
Local time
Tomorrow, 08:52
Joined
Dec 12, 2007
Messages
383
What you want to do is in your login form set ServerID to the value corresponding to the details used to login..

Since ServerID is a global variable, once set, it can be referenced throughout your database, even once you close the login form.
 

tom1252

Registered User.
Local time
Today, 23:52
Joined
Sep 18, 2009
Messages
96
once that is done how do i get it to put server id in a text box automaticlly
 

Funkyaccess

Registered User.
Local time
Today, 15:52
Joined
Oct 8, 2009
Messages
69
tom

as part of your forms on load event you can

say something like
Me.txtBox.controlsource= ServerID
 

Funkyaccess

Registered User.
Local time
Today, 15:52
Joined
Oct 8, 2009
Messages
69
In your forms's module declaration section include Option Explicit.
This means all variables must be explicitly declared. (It is a good practice to do this always.)
This command will set it:
ServerID = 1
If it isn't defiined Access will complain when you run the command.
Then you should be able to refer to it in any module and get that value.

What is ServerID? Is it related to user's login name?
Usename can be returned from this function:
Environ(username)
Correction: Environ("username")
 

tom1252

Registered User.
Local time
Today, 23:52
Joined
Sep 18, 2009
Messages
96
I must be doing something wrong cause it still dosent work.

Server Table

ServerID
ServerName
Passcode

SubTransaction form

SaleID _ auto number
ServerID - this needs to be done automaticlly
Date - Date()

I created a module not linked to anything and named it MODULE1

Code i used was Option

"Compare Database

Option Explicit

Public ServerID As Integer"


I then placed the statement you said into the code builder on the text box

Still not working. ANy Ideas? Thanks for all help anyway
 

Funkyaccess

Registered User.
Local time
Today, 15:52
Joined
Oct 8, 2009
Messages
69
tom,

with your form go into design view. open the properties windows (alt+enter) then got to form and then the event tab and find on load event and then click the "..." at the end of the field. then select code builder and then paste my example in and change txtbox to be the textbox name that you want updated.

If you stillgetting stuck upload it here and I'll go it for you.
 

tom1252

Registered User.
Local time
Today, 23:52
Joined
Sep 18, 2009
Messages
96
Hi still dosent work!!

It might be something to do with the auto number as it is a sub form when it goes on the transaction form the auto number needs be generated automaticlly if possible.

Thanks
 

Attachments

  • Login.zip
    23 KB · Views: 88

Zaeed

Registered Annoyance
Local time
Tomorrow, 08:52
Joined
Dec 12, 2007
Messages
383
I'm not sure about others, but I can't open that file you attatched..
 

tom1252

Registered User.
Local time
Today, 23:52
Joined
Sep 18, 2009
Messages
96
This one should work!
 

Attachments

  • Login.zip
    18.4 KB · Views: 85

Funkyaccess

Registered User.
Local time
Today, 15:52
Joined
Oct 8, 2009
Messages
69
Tom is this a cut down version?
I cant see where you setting ServerID. Where does your user login?
 

tom1252

Registered User.
Local time
Today, 23:52
Joined
Sep 18, 2009
Messages
96
Sorry forgot to include that!
 

Attachments

  • Login.zip
    237.4 KB · Views: 80

Users who are viewing this thread

Top Bottom