| Author |  | 
      
        | Guest Guest Group
 
  
 
 Joined: 10 November 2003
 Online Status: Online
 Posts: 262
 | 
          Hi Alex,
           | Posted: 11 November 2005 at 4:26pm | IP Logged |   |  
           | 
 |  
 I'm getting this error:
 "method 'Item' of object 'IMessages' failed"
 
 when I called:
 
 Dim lngSelectedMsg as Long
 lngSelectedMsg = myGrid.Row
 Set oMsg = oMsgs.Item(lngSelectedMsg)
 txtFrom.Text = oMsg.FromAddr
 txtTo.Text = oMsg.ToAddr
 txtSubj.Text = oMsg.Subject
 txtBody.Text = oMsg.BodyText
 
 I'm trying to display the selected message (from a flexgrid) to the interface.  Do you know what causes the problem?
 
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          Most likely, lngSelectedMsg index is out of range. For instance, oMsgs.Item(0) will cause an error.
           | Posted: 12 November 2005 at 12:05pm | IP Logged |   |  
           | 
 |  
 To be valid, the index value passed to Messages.Item method must be in the range 1 to Messages.Count. In other words, Messages collection index is one-based, while myGrid.Row index is probably zero-based.
 
 You may try this:
 
 
| Code: 
 
    
    | 
      
       | Set oMsg = oMsgs.Item(lngSelectedMsg + 1)
 
 |  |  |  
 Regards,
 Alex
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Guest Guest Group
 
  
 
 Joined: 10 November 2003
 Online Status: Online
 Posts: 262
 | 
          Hi Alex,
           | Posted: 14 November 2005 at 1:41pm | IP Logged |   |  
           | 
 |  
 Thanks for your reply.  When I run through debug mode, lngSelectedMsg is actually a non-zero.  When I click on the second row, the value of lngSelectedMsg is 2, but yet it seems to always fail to pass the line:
 
 Set oMsg = oMsgs.Item(lngSelectedMsg)
 
 Where can I look at the method 'Item' that contains 'IMessages'?  Thanks for your help.
 
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          Are you sure lngSelectedMsg=2 is valid for the given collection? lngSelectedMsg must be less or equal to oMsgs.Count. If oMsgs contains one or zero messages, oMsgs.Item(2) will fail.
           | Posted: 15 November 2005 at 9:52am | IP Logged |   |  
           | 
 |  
 IMessages is an internal name of Messages type. Thus, Item member reference can be found in MailBee documentation at "Reference/Messages Collection/Item Property" topic.
 
 Regards,
 Alex
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Guest Guest Group
 
  
 
 Joined: 10 November 2003
 Online Status: Online
 Posts: 262
 | 
          You're right.  In my code, lngSelectedMsg was initially a Long type, but after many re-uses it was converted to a string type and thus it was giving various errors.  Now it works, thanks a lot!
           | Posted: 18 November 2005 at 2:11pm | IP Logged |   |  
           | 
 |  
 
 | 
       
        | Back to Top |     | 
       
       
        |  |