Results 1 to 19 of 19

Thread: [RESOLVED] Urgent And Important!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    65

    Resolved [RESOLVED] Urgent And Important!

    Just 2 days left to complete the application!

    I have a table in database called accountholder and fields in that table known as
    intamount(means Intial Amount) and accbalance(Account Balance)

    I have a form in visual basic to create a new account, In that field there is intial account field, now the thing that i want to do is :-

    When an account is created, The initial amount entered into the database updates the account balance when the acount is created, so is there any code that updates the new account accbalance only and not all the records accbalance in the table.

    I'm not getting the sql statement.Please anybody!

    Regards,
    Muhammad Haris

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Urgent And Important!

    You would do an UPDATE tablename SET fieldname = whatever WHERE fieldname = whatever

    Without knowing your exact table and field structure I can't me more specific than that.

    What do you have for an SQL statement now that you can't get working.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    65

    Re: Urgent And Important!

    I have

    VB Code:
    1. cn.Execute "UPDATE accountholder SET accountholder.accbalance = [intamount]+[accbalance];"

    I can't get what to use for where clause as i want where to be accno of the newly created account!

    I can get you a screenshot of the database if you want...

    Last edited by Muhammad Haris; Feb 25th, 2006 at 07:23 AM.

  4. #4
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Re: Urgent And Important!

    At the time of creating the account, why don't you INSERT instead of UPDATE.
    INSERT INTO "your table name" (list of the fields in the table) VALUES
    (list of the values)

    OR
    You can use assign values to the fields programmatically :
    rs is the recordset variable containing refernce to your table

    VB Code:
    1. rs.fields("accno")= 'the value that should be contained by accno
    2. rs.fields("acctype") = 'the value of acctype

    and so on for all the fields.
    The argument passed to rs.fields must exactly match the field name in the table definition.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    65

    Re: Urgent And Important!

    I am getting a logic i will try and see what happens but update command is too important for me as the deposits and withdrawal will need those things to be done.Anyone got correct sql syntax?

    Anways , does anybody know how to show show sql statment result of adodc in a text file , for example

    text1.text = adodc1.recordsource "select name from accountholder where accno = 9"

    something like that
    Last edited by Muhammad Haris; Feb 25th, 2006 at 08:47 AM.

  6. #6
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Re: Urgent And Important!

    One more thing :
    Before programmatically assigning values :" rs.Addnew"
    After assigning the values : "rs.update "

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    65

    Re: Urgent And Important!

    Quote Originally Posted by Muhammad Haris
    I am getting a logic i will try and see what happens but update command is too important for me as the deposits and withdrawal will need those things to be done.Anyone got correct sql syntax?

    Anways , does anybody know how to show show sql statment result of adodc in a text file , for example

    text1.text = adodc1.recordsource "select name from accountholder where accno = 9"

    something like that
    Read my updated code!

  8. #8
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Re: Urgent And Important!

    I don't see what you want?
    If you want to see the values in the fields of the record source then you will have to draw a textbox for each field ,
    set the datasource property to the adodc control and
    datafield property to the field you want to display

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    65

    Re: Urgent And Important!

    Yes, I want to do that but I want to display the details regarding the accno i enter in the account number text box for example

    I enter account number 9 into accno.text and then in the accname.text it displays that account name that is in the accno 9 record.

    Any Ideas or a piece of code ?

  10. #10
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Re: Urgent And Important!

    how about this :
    Place all the textboxes for displaying the fields of the table.
    Have a separate textbox to enter the account number say txtaccno
    Then :
    adodc1.recordsource = "SELECT * FROM accountholder WHERE accno = " & trim$(txtaccno.text)

    This will let you see all the fields of the record

  11. #11
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Re: Urgent And Important!

    Since accno is autonumber field change trim$(txtaccno.text) to
    val(trim$(txtaccno.text))

  12. #12
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Re: Urgent And Important!

    One more thing after changing the recordsource you should call the refresh method of the adodc control

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    65

    Re: Urgent And Important!

    are the other text boxes suppose to be connected to the adodc1 data fields?

  14. #14
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Re: Urgent And Important!

    If you want to see just the name , then set the datasource and datafield property of the text box which is supposed to contain the name
    If you don't want other fields then you can omit them
    Last edited by srisa; Feb 25th, 2006 at 10:22 AM. Reason: forgot something

  15. #15
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Re: Urgent And Important!

    I am getting late , if you need anything more please hurry

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    65

    Re: Urgent And Important!

    There can be several meanings of what you are saying, Just let me know in detail , I am including account title, account name and account balance and when i enter like 1 or 2(the account no) i want to display data of that id.

    *I'm feeling like i'm the most newbiest person on the forum*

    Regards,
    Muhammad Haris

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    65

    Re: Urgent And Important!

    Please can you tell me what does trim do ?

    Regards,
    Muhammad Haris

  18. #18
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Re: Urgent And Important!

    trim removes the leading and trailing blank spaces.
    For every field that you want to display you need to draw a text box and set the datasource and datafield properties.
    Don't take offence. I have been working on the system for about 5 hours now and that is quite long for me

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    65

    Re: Urgent And Important!

    yeah srisa that worked, i'm feeling happy!

    Rep added!

    Thread Marked Resolved!

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