943,972 Members | Top Members by Rank

Ad:
Oct 1st, 2007
0

appear in other form

Expand Post »
hello. my problem is, after login username and password in one form, then a new form will be appear. how to create coding to insert username in a label at new form after login. i have tried this coding but still not appear. please help me. thanks.....


Public Sub loadInfo()
On Error Resume Next

checkConnection
strSql = "SELECT Username FROM Customer WHERE Psswd='" & strPsswd & "'"
rec1.Open strSql, con, adOpenStatic

lblUsername.Caption = rec1!Username
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aynn is offline Offline
4 posts
since Sep 2007
Oct 1st, 2007
0

Re: appear in other form

say u have two forms

form1
form2

in form1's any sub refer to form2's element

public sub loadinfo()
..
..
form2.lblUsername.Caption = rec1.Username
end sub
Reputation Points: 10
Solved Threads: 2
Light Poster
hussulinux is offline Offline
41 posts
since Feb 2007
Oct 1st, 2007
0

Re: appear in other form

thanks. but still username not appear in other form.....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aynn is offline Offline
4 posts
since Sep 2007
Oct 1st, 2007
0

Re: appear in other form

It will not, try to check if the username is appearing from the database.
check by this:
MsgBox rec1.username
Reputation Points: 10
Solved Threads: 2
Light Poster
hussulinux is offline Offline
41 posts
since Feb 2007
Oct 2nd, 2007
0

Re: appear in other form

Click to Expand / Collapse  Quote originally posted by aynn ...
hello. my problem is, after login username and password in one form, then a new form will be appear. how to create coding to insert username in a label at new form after login. i have tried this coding but still not appear. please help me. thanks.....


Public Sub loadInfo()
On Error Resume Next

checkConnection
strSql = "SELECT Username FROM Customer WHERE Psswd='" & strPsswd & "'"
rec1.Open strSql, con, adOpenStatic

lblUsername.Caption = rec1!Username

use this approach in ur coding :-

1. add a standard module in ur project from project->add module
2. in the module declare a public variable to store the username.the sysntax is :-
Public strUsername as String
3. then in the login form whenver you enter the username and password and hit the login button just pass the username to the above variable. the syntax is :-
strUsername=<your username>
4. after this you can access the value you just have passed to this variable from each and every form of your project. like in form2' label :-
LblUsrname.Caption=strUsername

Note : a public variable has a wide range than the usual standard variables which we declare using the 'Dim' keyword. Public variables are always declared by the 'Public' keyword and it has the effect to the entire project.

hope it will solve out ur probs.

regards
Shouvik
Reputation Points: 30
Solved Threads: 49
Posting Pro
choudhuryshouvi is offline Offline
553 posts
since May 2007
Oct 2nd, 2007
0

Re: appear in other form

Make the variable storin g the username a public variable in a standard module.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Oct 15th, 2007
0

Re: appear in other form

hi.
for your solution.

instructions:
create the labels ie Label1 (for the username), in the form you wish you display to.
Then in that form eg frmLoggedin, write this code:

Private Label1()
Label1.Caption= frmLogIn.txtUserName.texxt
End Sub

That is all you have to do fro the Logged in User to see their UserName after log in.
NB: The frmLogIn is the form that you are using to login to the system
The frmLoggedIn is the form you would like to display the UserName logged in.

For more details just mail back.
Thanks.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Lavendor is offline Offline
8 posts
since Aug 2007
Oct 15th, 2007
0

Re: appear in other form

use a global variable to hold the data (use public instead of dim) and then any form can use it
Moderator
Featured Poster
Reputation Points: 1800
Solved Threads: 575
Moderator
jbennet is offline Offline
16,520 posts
since Apr 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: How to assure data gets stored in MS Access
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: How to find 2 highest numbers





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC