Results 1 to 3 of 3
  1. #1
    jermaine123 is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    10

    Issue with while loop and Access 2007 datasheet

    Hello Guys,

    I have modified the order details form in Northwind 2007 and I am having an
    issue I hope you can help me with. It is a form with a dataaheet that you use
    to enter line items into a transaction. Each row contains the fields ITEMNAME,
    QUANTITY PRICE, DISCOUNT, SUBTOTAL, BENEFIT TYPE.

    Each line item in a transaction should be assigned to a particular benefit
    type. I have a piece of code that goes through the data sheet and checks to
    make sure that the benefit type field is not empty.

    The problem I am having is that if I enter 3 items and dont put a benefit
    type for any of them,- When I click the COMPLETE TRANSACTION button I will
    get the message box "You need to enter a benefit type".

    If I put in the benefit type for one of the three items and click the
    COMPLETE TRANSACTION button again, I do not get the error message box again,
    instead it closes the transaction.

    Each time I click the COMPLETE TRANSACTION button I would like it to go
    through each line item and check if it has a benefit type entered and if not
    show a mesage box.

    Hope my post makes sense. I am sure it is something simple, but I am just not
    seeing it.

    Thanks

    The code is below....

    Dim rsw As New RecordsetWrapper
    With rsw.GetRecordsetClone(Me.sbfOrderDetails.Form.Reco rdset)
    ' Check that we have at least one specified line items
    If .RecordCount = 0 Then
    MsgBoxOKOnly OrderDoesNotContainLineItems
    Else
    Dim LineItemCount As Integer
    LineItemCount = 0
    While Not .EOF
    LineItemCount = LineItemCount + 1

    If IsNull(Forms![Order Details]![sbfOrderDetails].Form![Product
    ID]) Then
    MsgBoxOKOnly MustSpecifyItemName
    Exit Function

    ElseIf IsNull(Forms![Order Details]![sbfOrderDetails].Form!
    [Benefit ID]) Then
    MsgBoxOKOnly MustSpecifyBenefitType
    Exit Function


    End If
    rsw.MoveNext
    Wend

    ValidateOrder = True
    eh.TryToSaveRecord
    Me![Status ID] = Closed_CustomerOrder
    MsgBoxOKOnly OrderMarkedClosed
    SetFormState


    End If
    End With

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    I would cycle through a snapshot recordset for the form control source checking the requisite fields and building the messag(s) accordingly.

  3. #3
    KLynch0803 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    37
    I'm no proffessional but maybe this will strike you an idea etc.

    Why not add something like this after your "rsw.movenext" or in the propper place..

    Code:
    do until rsw.EOF
    Loop

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

Similar Threads

  1. MS Access 2003+Ms Excel 2007 Issue
    By putnum in forum Access
    Replies: 3
    Last Post: 12-20-2009, 09:24 PM
  2. Replies: 0
    Last Post: 11-17-2009, 02:35 PM
  3. For Each LOOP statement
    By zambam737 in forum Programming
    Replies: 3
    Last Post: 10-26-2009, 09:59 PM
  4. MS Access 2007 - network interruption issue
    By shsh_shah in forum Access
    Replies: 5
    Last Post: 10-11-2009, 09:47 AM
  5. concatenate string using loop
    By nengster in forum Programming
    Replies: 0
    Last Post: 02-23-2009, 08:05 PM

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