Results 1 to 3 of 3
  1. #1
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Modify Loop (2002 SP-2)

    Now I understand what HansV meant by whether I really wanted to interupt a process with a msgbx (it pops up every time the On Timer event fires, even though there's no new info). In the follwing code (extracting info from a received OL e-mail), I would now like to remove the msgbx and add blnWeight to the UPDATE portion of the strSQL. This way I can see from the check-box (blnWeight) in the continuous form that a particular order has been amended. As good as I am at butchering code, I thought I'd better ask for help right up front.
    <pre> ' Loop through mail items
    For i = lngNumItems To 1 Step -1
    Set objOLItem = objOLFolder.Items(i)
    strSubject = objOLItem.Subject
    ' Check if subject contains PRO#
    intPos = InStr(strSubject, "PRO# ")
    If intPos > 0 Then
    ' Assemble SQL string
    strProNo = Val(Mid(strSubject, intPos + 5))
    strReceived = "#" & Format(objOLItem.ReceivedTime, "mm/dd/yyyy hh:mm AM/PM") & "#"
    lngWeight = ExtractNumber(objOLItem.Body)
    strSQL = "UPDATE tblMaster SET datWeight=" & _
    strReceived & ",lngWeight=" & lngWeight & " WHERE ProNo=" & strProNo & _
    " And (datReceived Is Null Or datReceived<" & strReceived & ")"
    If MsgBox("You are about to update the weight for PRO#" & strProNo & _
    ". Continue?", vbQuestion + vbYesNo = vbYes) Then
    ' Update record
    CurrentDb.Execute strSQL
    End If
    End If
    Next i</pre>

    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Modify Loop (2002 SP-2)

    Like this:
    <pre> ' Loop through mail items
    For i = lngNumItems To 1 Step -1
    Set objOLItem = objOLFolder.Items(i)
    strSubject = objOLItem.Subject
    ' Check if subject contains PRO#
    intPos = InStr(strSubject, "PRO# ")
    If intPos > 0 Then
    ' Assemble SQL string
    strProNo = Val(Mid(strSubject, intPos + 5))
    strReceived = "#" & Format(objOLItem.ReceivedTime, "mm/dd/yyyy hh:mm AM/PM") & "#"
    lngWeight = ExtractNumber(objOLItem.Body)
    strSQL = "UPDATE tblMaster SET datWeight=" & _
    strReceived & ", lngWeight=" & lngWeight & _
    ", blnWeight = True WHERE ProNo=" & strProNo & _
    " And (datReceived Is Null Or datReceived<" & strReceived & ")"
    CurrentDb.Execute strSQL
    End If
    Next i
    </pre>

    The SQL statement has been expanded (take care of those underscores!) and the If ... Then statement with the MsgBox has been removed.

  3. #3
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Modify Loop (2002 SP-2)

    <img src=/S/bullseye.gif border=0 alt=bullseye width=45 height=15> Beautiful, perfect, excellant! I promise to never question your intuitive nature again.
    (Bad Bryan. . .return to cave and remain quiet.)
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

Posting Permissions

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