|
-
Nov 24th, 2005, 03:14 AM
#1
Thread Starter
New Member
Help With Data Bases
Alright this website has been awesome for me so far I had a problem and was directed to a sight for help, now I got a new problem. My program I am using figures up a check book balance and makes a summary of the account, my problem is that I dont know how to make the last value in the balance column to add it to my next entry also I am wanting to insert the balance in a label but I think I know how to do that but it is just getting it to update cause if I add an entry it is in a new column I didnt know how to increment thanks for any help code help will be best but any help is better than none.
-
Nov 24th, 2005, 04:24 AM
#2
Re: Help With Data Bases
Take a breath and use some punctuation, man. It's not really clear from your post what you want. You talk about columns, but columns of what? Where is all this data held and how is being displayed? To display something in a Label is just a matter of assigning it to the Text property, but there's obviously more to this than just that. Try to be a bit more specific with what you are doing and what you want to achieve. Also, post some code if it will illustrate your point.
-
Nov 24th, 2005, 10:43 PM
#3
Thread Starter
New Member
Re: Help With Data Bases
Ok here it is, My program takes information from the user about a deposit or a debit. Then the program posts the information in to a database. The columns are description, amount, location, date, and balance. The problem I am having is getting the balance to post. I am not sure if there is a way to use the last row of the balance column in an algorithm to add to the balance for the next entry. Any ideas would be awesome.
-
Nov 24th, 2005, 11:02 PM
#4
Re: Help With Data Bases
So basically you want to get the value in the balance column of the previous record so you can add the value in the amount column of the current record to give you the balance for the current record, correct? If so, then you're going to have to use a query to get the balance from the previous record. You could do it in two steps by first getting the value from the previous record, doing the calculation and then inserting the new record with the calculated value, but you should be able to do it in a single step using a subquery, something like this:
Code:
INSERT INTO Transactions SET Amount = @Amount AND Balance = (SELECT TOP Balance FROM Transactions ORDER BY [Date] DESC) - @Amount
That is untested and I'm by no means an SQL guru, but either that or something like that should do the trick I think.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|