Results 1 to 1 of 1
  1. #1
    tuyo is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    9

    Smile for each statement in vba

    hi! im making an inventory in access 2007. i created a macro in vba that would check if there is an existing record based on the form information. i want the opening balance to carry over the ending balance. now, the problem comes in.


    1. the ending balance does not display on the forms opening balance
    2. if there are multiple items that meet the criterias, i should sort the dates and get the closest to the most recent date.

    heres my code so far. (ps.im just a newbie)

    With a
    Do Until .EOF
    For Each flddist In .Fields
    If flddist.Name = "Dist/Customer" Then
    If flddist.Value = b![Dist/Customer] Then

    For Each fldbranch In .Fields
    If fldbranch.Name = "Branch" Then
    If fldbranch.Value = b!Branch Then

    For Each fldItem In .Fields
    If fldItem.Name = "ItemDescription" Then
    If fldItem.Value = b![ItemDescription] Then


    For Each flddate In .Fields
    If flddate.Name = "Date Received/dispatched" Then

    'insert choose the most recent entry

    For Each fldending In .Fields
    If fldending.Name = "EndingBalance" Then
    b![BegBalance] = fldending.Value
    MsgBox "found"
    Exit For
    End If
    Next


    End If
    Next

    End If
    End If
    Next


    End If
    End If
    Next

    Exit For
    End If
    Else
    b![BegBalance] = 0
    End If
    Next
    .MoveNext
    Loop

    End With
    Exit Sub

    BegBalance_Error:
    MsgBox "An error has occured"

    End Sub

    opinions are very much welcome. Thanks guys!
    Last edited by tuyo; 03-22-2011 at 08:35 PM.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. iff Statement
    By tkandy in forum Access
    Replies: 0
    Last Post: 03-20-2011, 02:31 PM
  2. SQL like statement?
    By Cojack in forum Queries
    Replies: 4
    Last Post: 09-21-2010, 04:45 AM
  3. Help with Iif statement
    By tmcrouse in forum Queries
    Replies: 2
    Last Post: 09-02-2010, 09:00 AM
  4. IIf Statement...HELP!
    By bdhFS in forum Queries
    Replies: 5
    Last Post: 05-19-2010, 07:55 AM
  5. IIF statement
    By james1982 in forum Access
    Replies: 1
    Last Post: 07-20-2009, 09:38 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums