Hello,
I am a bit new to VB & Access. I Had wrote a simple program designed for my company to input / request & send new quotes. I do feel thatsome of it was done incorrectly but it works.. I am now creating a much larger program & data base to replace one that coded years ago by prior owner. Unfortunately he wrote the software to work with specific programs that are now no longer supported. I ordered a few books off the internet but after goggling found i will find much more success and help from working with other user's like yourself.
The new software i am writing is for international shipping company. I understand that ACCESS can use its own CurrentUser() feature for security however i needed to create my own login prompt. I have a table Named "Users" which contains an autonumber Id / UserName & password. I created a form (AECLmainlogin) which has a combo box (AECLusername) where user is selected from the table column 1. I then have a textbox named (AECLpassword) where the user entered their numeric / alpha password & a command button (AECLmainloginCmd) which sets the code in action.
Upon Clicking the command it calls "CheckLogin ()" which is a module i created. It verifies the username & password are correct in the table, if not clear password & msgbox " enter password ". This part works 100%.
Once this happens what i need to have happen is to open a new form (AECLmainmenu). On that mainmenu & through the rest of the forms i create (based on different tables for the auctual shipping information) I have created a menu bar at the top. On that menu bar i need it to show the current user which was logged in. I have tried many different things.. some with partial success.. I had written a module which was called GetUserName() I then set the control of the New Textbox on the menu bar to GetUserName() Sometimes it writes ?NAME & Othertimes it will show the user but overwrites the information on line 1 table "USERS". Here is what i have.. im very confused and appreciate any help or guidance on how i can accomplish this with or without the code i wrote. The attached is just test db i have been using to figure this out. Username/ pw are in there.
__________________________________________________ __________________________________________________ ______________________________
This is my login form i created Form_AECLmainlogin
Option Compare Database
Public Sub AECLmainloginCmd_Click()
Call CheckLogIn
End Sub
__________________________________________________ __________________________________________________ _______________________________
This is my module - CheckMainLogin
Option Compare Database
Public Function CheckLogIn()
''Check that User is selected
If IsNull(Form_AECLmainlogin.AECLUserName.Column(0)) Then
MsgBox "You need to select a user!", vbCritical
Form_AECLmainlogin.AECLUserName.SetFocus
Else
'Check for correct password to be correct. if yes it opens mainpage if not go back to login
If Form_AECLmainlogin.AECLpassword = Form_AECLmainlogin.AECLUserName.Column(1) Then
Call GetCurrentUserLoggedIn
DoCmd.OpenForm ("CurrentUserName")
Else
MsgBox "Password does not match, please re-enter!", vbOKOnly, "Password Incorrect"
Form_AECLmainlogin.AECLpassword = Null
Form_AECLmainlogin.AECLpassword.SetFocus
End If
End If
End Function
__________________________________________________ __________________________________________________ ______________________________
This is my module - GetUserLogin
Option Compare Database
Dim UserName As String
Public Function GetCurrentUserLoggedIn()
UserName = Form_AECLmainlogin.AECLUserName
GetCurrentUserLoggedIn = UserName
End Function
I am a bit new to VB & Access. I Had wrote a simple program designed for my company to input / request & send new quotes. I do feel thatsome of it was done incorrectly but it works.. I am now creating a much larger program & data base to replace one that coded years ago by prior owner. Unfortunately he wrote the software to work with specific programs that are now no longer supported. I ordered a few books off the internet but after goggling found i will find much more success and help from working with other user's like yourself.
The new software i am writing is for international shipping company. I understand that ACCESS can use its own CurrentUser() feature for security however i needed to create my own login prompt. I have a table Named "Users" which contains an autonumber Id / UserName & password. I created a form (AECLmainlogin) which has a combo box (AECLusername) where user is selected from the table column 1. I then have a textbox named (AECLpassword) where the user entered their numeric / alpha password & a command button (AECLmainloginCmd) which sets the code in action.
Upon Clicking the command it calls "CheckLogin ()" which is a module i created. It verifies the username & password are correct in the table, if not clear password & msgbox " enter password ". This part works 100%.
Once this happens what i need to have happen is to open a new form (AECLmainmenu). On that mainmenu & through the rest of the forms i create (based on different tables for the auctual shipping information) I have created a menu bar at the top. On that menu bar i need it to show the current user which was logged in. I have tried many different things.. some with partial success.. I had written a module which was called GetUserName() I then set the control of the New Textbox on the menu bar to GetUserName() Sometimes it writes ?NAME & Othertimes it will show the user but overwrites the information on line 1 table "USERS". Here is what i have.. im very confused and appreciate any help or guidance on how i can accomplish this with or without the code i wrote. The attached is just test db i have been using to figure this out. Username/ pw are in there.
__________________________________________________ __________________________________________________ ______________________________
This is my login form i created Form_AECLmainlogin
Option Compare Database
Public Sub AECLmainloginCmd_Click()
Call CheckLogIn
End Sub
__________________________________________________ __________________________________________________ _______________________________
This is my module - CheckMainLogin
Option Compare Database
Public Function CheckLogIn()
''Check that User is selected
If IsNull(Form_AECLmainlogin.AECLUserName.Column(0)) Then
MsgBox "You need to select a user!", vbCritical
Form_AECLmainlogin.AECLUserName.SetFocus
Else
'Check for correct password to be correct. if yes it opens mainpage if not go back to login
If Form_AECLmainlogin.AECLpassword = Form_AECLmainlogin.AECLUserName.Column(1) Then
Call GetCurrentUserLoggedIn
DoCmd.OpenForm ("CurrentUserName")
Else
MsgBox "Password does not match, please re-enter!", vbOKOnly, "Password Incorrect"
Form_AECLmainlogin.AECLpassword = Null
Form_AECLmainlogin.AECLpassword.SetFocus
End If
End If
End Function
__________________________________________________ __________________________________________________ ______________________________
This is my module - GetUserLogin
Option Compare Database
Dim UserName As String
Public Function GetCurrentUserLoggedIn()
UserName = Form_AECLmainlogin.AECLUserName
GetCurrentUserLoggedIn = UserName
End Function