•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 456,552 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,477 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 1990 | Replies: 3
![]() |
•
•
Join Date: Oct 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
Hi
I am creating an MDI application that carries out various tasks >> Login, View Balance, Show Transactions, Request Statement.
So far I have only managed to create the Parent MDI, Main menu to be able to choose a function, and login validation.
Login Code:
Dim str As String = "Provider = Microsoft.jet.OLEDB.4.0;Data Source =C:\....\bin\CustomerDetails.mdb"
Dim conn As New OleDb.OleDbConnection(str)
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim cmd As New OleDb.OleDbCommand("select * from SecurityTable where AccountNo='" + txtAccountNo.Text + "'", conn)
conn.Open()
Try
Dim rdr As OleDb.OleDbDataReader = cmd.ExecuteReader
If rdr.Read Then
Dim p As String = rdr(1)
If txtPassword.Text = p Then
MessageBox.Show("Welcome !!")
Me.Close()
Else
MsgBox(" Invalid Password!! Please try again ")
txtPassword.Text = ""
txtPassword.Focus()
End If
Else
MsgBox(" Invalid Username!! Please try again ")
txtAccountNo.Text = ""
txtPassword.Text = ""
txtAccountNo.Focus()
End If
conn.Close()
Catch ex As Exception
MsgBox(ex.Message)
conn.Close()
End Try
End Sub
The above code works successfully. It retrieves data from MS Access Security Table and allows the user to access the main menu commands in the Parent form.
The PROBLEM that I have now is in retrieving specific records/fields for that particular user that is logged in.
For example, I have created a form named Balance which is displayed once the miViewBalance is clicked. In it I want to show in a label or TextBox the Name, Surname and Balance for that specific user.
I already have a MS Access Table that contains the details such as name, surname, address, account type, etc. All I want is to display some fields in the Balance Form.
CAN ANYBODY HELP ME WITH THE CODE PLEASE?
Code for retrieving data from Access and displaying it in label or Textbox for the specific user that is logged in the application.
I am creating an MDI application that carries out various tasks >> Login, View Balance, Show Transactions, Request Statement.
So far I have only managed to create the Parent MDI, Main menu to be able to choose a function, and login validation.
Login Code:
Dim str As String = "Provider = Microsoft.jet.OLEDB.4.0;Data Source =C:\....\bin\CustomerDetails.mdb"
Dim conn As New OleDb.OleDbConnection(str)
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim cmd As New OleDb.OleDbCommand("select * from SecurityTable where AccountNo='" + txtAccountNo.Text + "'", conn)
conn.Open()
Try
Dim rdr As OleDb.OleDbDataReader = cmd.ExecuteReader
If rdr.Read Then
Dim p As String = rdr(1)
If txtPassword.Text = p Then
MessageBox.Show("Welcome !!")
Me.Close()
Else
MsgBox(" Invalid Password!! Please try again ")
txtPassword.Text = ""
txtPassword.Focus()
End If
Else
MsgBox(" Invalid Username!! Please try again ")
txtAccountNo.Text = ""
txtPassword.Text = ""
txtAccountNo.Focus()
End If
conn.Close()
Catch ex As Exception
MsgBox(ex.Message)
conn.Close()
End Try
End Sub
The above code works successfully. It retrieves data from MS Access Security Table and allows the user to access the main menu commands in the Parent form.
The PROBLEM that I have now is in retrieving specific records/fields for that particular user that is logged in.
For example, I have created a form named Balance which is displayed once the miViewBalance is clicked. In it I want to show in a label or TextBox the Name, Surname and Balance for that specific user.
I already have a MS Access Table that contains the details such as name, surname, address, account type, etc. All I want is to display some fields in the Balance Form.
CAN ANYBODY HELP ME WITH THE CODE PLEASE?
Code for retrieving data from Access and displaying it in label or Textbox for the specific user that is logged in the application.
as you did here
you can show the data in lable or textbox
•
•
•
•
Dim p As String = rdr(1)
If txtPassword.Text = p Then
you can show the data in lable or textbox
textbox1.text=rdr("column_name") "give only what u willing to receive "
•
•
Join Date: Oct 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
Hi there Manal 
I managed like you said!
Twisted the code around to make it appropriate for the View Balance bit, as follows :
Private Sub btnBalance_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBalance.Click
Dim cmd As New OleDb.OleDbCommand("select AccountNo,Password,Title,Name,Surname from AccountDetails where AccountNo='" + txtAccountNo.Text + "'", conn)
conn.Open()
Try
Dim rdr As OleDb.OleDbDataReader = cmd.ExecuteReader
If rdr.Read Then
Dim p As String = rdr(1)
If txtPassword.Text = p Then
Label3.Text = rdr(2)
Label4.Text = rdr(3)
Label5.Text = rdr(4)
This way ... once the form is uploaded and the user re-enters the account no and password ... details will be shown.
You had already replied to my previous post, but I wasn't getting anywhere. Second time around I managed ... so THANKS A lot
Just want to add ....
I don't know if you can help .... is there a way how I can eliminate re-entering the account no and password in the Balance form.
Example .... to get data from Login form entries. This way the user does not have to re-enter his login details.

I managed like you said!
Twisted the code around to make it appropriate for the View Balance bit, as follows :
Private Sub btnBalance_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBalance.Click
Dim cmd As New OleDb.OleDbCommand("select AccountNo,Password,Title,Name,Surname from AccountDetails where AccountNo='" + txtAccountNo.Text + "'", conn)
conn.Open()
Try
Dim rdr As OleDb.OleDbDataReader = cmd.ExecuteReader
If rdr.Read Then
Dim p As String = rdr(1)
If txtPassword.Text = p Then
Label3.Text = rdr(2)
Label4.Text = rdr(3)
Label5.Text = rdr(4)
This way ... once the form is uploaded and the user re-enters the account no and password ... details will be shown.
You had already replied to my previous post, but I wasn't getting anywhere. Second time around I managed ... so THANKS A lot
Just want to add ....
I don't know if you can help .... is there a way how I can eliminate re-entering the account no and password in the Balance form.
Example .... to get data from Login form entries. This way the user does not have to re-enter his login details.
•
•
•
•
I don't know if you can help .... is there a way how I can eliminate re-entering the account no and password in the Balance form.
Example .... to get data from Login form entries. This way the user does not have to re-enter his login details.
what I understand that you have two forms , one for logging in and the other one to show information for corresponding user , right?
then yes it is better to eliminate re-entering account's information in the other form , or there will be no need for log in form , you can pass the value you got in first parent form(log in form) to the child form(balance_info form)) ,
you can pass the txtAccountNo.text as parameter for the child form's constructor
If txtPassword.Text = p Then
MessageBox.Show("Welcome !!")
Dim initial As String
initial = Me.txtAccountNo.Text
Dim form2 As Form2
' Create the child form.
form2 = New Form2(initial)
form2.Show()in the form2 you need to overload the constructor
read this artical to show you how you can pass values between forms(or any objects)
good luck
Last edited by manal : Oct 23rd, 2007 at 3:54 pm.
"give only what u willing to receive "
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Data retrieving using ms-access (VB.NET)
- inserting variable value into fields in access? (Visual Basic 4 / 5 / 6)
- Problem with retrieving data from access 2003 (Visual Basic 4 / 5 / 6)
- Date fields imported from access file to excel spreadsheet is converting to number (Visual Basic 4 / 5 / 6)
- updating fields in MS Access (Perl)
- Access INSERT problem (MS Access and FileMaker Pro)
- having problem in retrieving data from MS ACCESS (Visual Basic 4 / 5 / 6)
Other Threads in the VB.NET Forum
- Previous Thread: Interrupt Do While Loop
- Next Thread: CHecking for Duplicates


Linear Mode