Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Posts
    1

    Unhappy Unanswered: help a newbie out

    i have a class in access and im running into a problem maybe someone can help me out.

    in microsoft access xp i am trying to calculate 2 feilds the "on hand" and the "cost" for all the records on the table. if i was to do it individually it would be something like cost * on hand = toatal. so i tried [cost]*[on hand] but it didnt turn out right. any help would be great thanks in advance.

    -dbnoob

  2. #2
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    i've never used XP but i wouldn't think it was much different,

    now you didn't say where you were trying to do this, if in SQL Try
    Code:
    SELECT Sum([cost]*[on hand]) AS total
    in vb i think the easest way would be
    Code:
    Private Sub Yes_Click()
    On Error GoTo Err_yes_Click
        DoCmd.GoToRecord , , acFirst
        Do
            total= total + [cost]*[onHand]
            DoCmd.GoToRecord , , acNext
        Loop
    Err_yes_Click
    End Sub
    Last edited by m.timoney; 11-18-02 at 06:28.
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  3. #3
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: help a newbie out

    Originally posted by DBn00b
    i have a class in access and im running into a problem maybe someone can help me out.

    in microsoft access xp i am trying to calculate 2 feilds the "on hand" and the "cost" for all the records on the table. if i was to do it individually it would be something like cost * on hand = toatal. so i tried [cost]*[on hand] but it didnt turn out right. any help would be great thanks in advance.

    -dbnoob
    IF IN FORM THEN TRY TO OPEN THE RECORD FROM SQLSTMT
    AND CALCUTATE THESE FIELDS IN SQL STATEMENT

    Dim SQLSTmt as STring
    Dim adrs as recordset

    SQLSTmt= "Select sum([cost]*[On hand] ) as Totalfrom tablename"
    set adrs= adrs.openRecordset(SQLStmt,DB_OPEN_DYNASET)

Posting Permissions

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