Need Assistance With Basic VB Module / Return String

Shaunk23

Registered User.
Local time
Today, 17:22
Joined
Mar 15, 2012
Messages
118
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
 

Attachments

You have bound the form and the controls to the data source. As a result, if the user enters data in the controls, they modify the data in the source. Delete the ControlSource property of the controls on the form, and delete the RecordSource property of the form so that the form and its controls are 'unbound.'
Then, handle the button click and only at that time compare the data entered in the form to data you retrieve from the table. In this way you can confirm, or not, that the data entered in the form ALSO exists in the table.
Cheers,
 
You have bound the form and the controls to the data source. As a result, if the user enters data in the controls, they modify the data in the source. Delete the ControlSource property of the controls on the form, and delete the RecordSource property of the form so that the form and its controls are 'unbound.'
Then, handle the button click and only at that time compare the data entered in the form to data you retrieve from the table. In this way you can confirm, or not, that the data entered in the form ALSO exists in the table.
Cheers,


Thank you so much!! Its very nice for your help.. i had posted on another forum & the ppl who responded were nasty & sarcastic! Not everyone is an expert! Some people like me are forced to write a database running a small business on budget! Thanks again & im sure ill be posting more. I atleast am moving forward now. As far as needing assistance here i have seen your name all over the pages with response. Should i just post every time i have a question or send a private message? Thanks again!

-Shaun
 
No need to PM.
- First, search the forum, which is your fastest way to find info. Almost certainly someone has asked a similar question over the years.
- Second, if your search terms aren't returning useful threads, ask a public question. This way everyone using the forum might benefit from the exchange.
Have a good one!
Mark
 

Users who are viewing this thread

Back
Top Bottom