appear in other form

Reply

Join Date: Sep 2007
Posts: 4
Reputation: aynn is an unknown quantity at this point 
Solved Threads: 0
aynn aynn is offline Offline
Newbie Poster

appear in other form

 
0
  #1
Oct 1st, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 41
Reputation: hussulinux is an unknown quantity at this point 
Solved Threads: 2
hussulinux hussulinux is offline Offline
Light Poster

Re: appear in other form

 
0
  #2
Oct 1st, 2007
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
Hussain Fakhruddin
Teks: http://www.teks.co.in
hussulinux at gmail dot com
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 4
Reputation: aynn is an unknown quantity at this point 
Solved Threads: 0
aynn aynn is offline Offline
Newbie Poster

Re: appear in other form

 
0
  #3
Oct 1st, 2007
thanks. but still username not appear in other form.....
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 41
Reputation: hussulinux is an unknown quantity at this point 
Solved Threads: 2
hussulinux hussulinux is offline Offline
Light Poster

Re: appear in other form

 
0
  #4
Oct 1st, 2007
It will not, try to check if the username is appearing from the database.
check by this:
MsgBox rec1.username
Hussain Fakhruddin
Teks: http://www.teks.co.in
hussulinux at gmail dot com
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 537
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: appear in other form

 
0
  #5
Oct 2nd, 2007
Originally Posted by aynn View 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

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
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,086
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 125
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: appear in other form

 
0
  #6
Oct 2nd, 2007
Make the variable storin g the username a public variable in a standard module.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 8
Reputation: Lavendor is an unknown quantity at this point 
Solved Threads: 0
Lavendor Lavendor is offline Offline
Newbie Poster

Re: appear in other form

 
0
  #7
Oct 15th, 2007
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.
Lavendor
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,144
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 530
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: appear in other form

 
0
  #8
Oct 15th, 2007
use a global variable to hold the data (use public instead of dim) and then any form can use it
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC