A1VBCode Forums

ATM Project - Displaying a Balance in a textbox depending on the PIN number entered


http://www.a1vbcode.com/vbforums/Topic32142.aspx

By Sarah123 - 3/18/2014

Hi all,



I'm working on a project using VB 2010 Professional.

The project I'm building is an ATM project which has a log in form for customers where they enter their Name and their PIN number which are stored in an Access database that I have connected the project to.



I have the code working so that the Name and PIN that are entered must match the same customer in the database (eg. in the DB, John Doe's PIN is 1234 so on the login form John Doe can't enter anything other than 1234).

I'm using code like: "SELECT * from Account Where Customer_Name='" & UserNameTextBox.Text



This part of the project is working fine but I was wondering if anyone can help me with this problem: There is a button on the ATM form called btnBalance. When this is clicked I want the TextBox1 to show the Balance that is stored in the DB depending on which customer is logged in at the time. Can anybody help me with this?



Any help is appreciated, thanks! Also, sorry if I didn't word this very well, I'm a completely newbie with VB.


By Destroyer - 3/23/2014

Hi Sarah,



Is the account balance stored in the same database table as the login info? Is so, you have already retrieved the balance for the logged in user with your Select statement below.



SELECT * from Account Where Customer_Name='" & UserNameTextBox.Text



Then it's just a matter of assigning the balance retrieved from the table via your Select statement to the textbox.



Something like, TextBox1.Text = rsBalance