Results 1 to 4 of 4

Thread: Help With Data Bases

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    4

    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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    4

    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.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width