Forum Discussion

mcmprashanth's avatar
mcmprashanth
Occasional Contributor
11 years ago

run time error, 'object variable not set'


Hi,

Can anyone help where my script is going wrong pls. The error is thrown at 'If nRow = ("Local") Then' script line. thanks in advance.



Sub selectrow

 Dim nRow

 Dim tblCell

 Dim pnlObj

 Dim tblObj



  Set pnlObj = Sys.Browser().Page().Form().Panel()

  Set tblObj = pnlObj.Object(dir).SlObject("gridfrmobj").SlObjec("Grid").SlObject("dataPresenter")

  For i = 0 to tblObj.ChildCount - 1

  Set tblCell = tblObj.SlObject("TextEdit", "", i)

  Set nRow = tblCell.EditValue

  If nRow = ("Local") Then

  Log.Message("FOUND")

  tblCell.ClickR

  'ElseIf ...

   .........

  Exit For

  End If

  Next

End Sub


4 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi,



    Quite a wild guess as I have no idea about your application, but I would suggest this correction:

    instead of

      Set nRow = tblCell.EditValue

      If nRow = ("Local") Then




    try

      nRow = tblCell.EditValue

      If nRow = "Local" Then






    Hope it will help...



    Anyway, you can put a breakpoint on the "nRow = tblCell.EditValue" line and examine using the Evaluate dialog what type of value (object, integer, string, ...) is returned by the tblCell.Value expression.

  • mcmprashanth's avatar
    mcmprashanth
    Occasional Contributor
    Thanks Karas,



    Using  nRow = tblCell.EditValue

              If nRow = ("Local") Then

    makes no difference. Tried using Evaluate Dialog but by the time script starts executing and accepting pause key to activate Evaluate Dialog, the script throws error leaving no space. However, EditValue is showing up as string in object browser, if that makes any sense. Any other way please?






  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi tester,


     


    I'm not sure what you are enclosing the "Local" string in brackets for. Remove them so that your code looks like this:




     

  • Hi Tanya,



    Sorry that accidentally I typed ("Local") instead of "Local" in my last post. So, thats not the solution really.

    Now, the 'EditValue property' I used in my script is then when I saw other properties ('DisplayText' property or 'wValue' property) of the grid cells were not having correct values. I can still use those other properties using same script.

    Another issue is if at all I use other properties of the grid cells to choose and Click on them, I found that last one row and its cells are not displayed in my object browser. So, I cant prepare script to access those cells and Click on them. I wonder why my object browser is not recognising last row of the grid although other rows and cells above to last row are recognised and displayed in object browser (half of my grid is not visible on the page. scrolling needed to view them). Am using 'MouseWheel' to access invisible grid rows as Extended properties show wvalue property only and using chekpoint clicks on coordinates not on the page but somewhere below on the task bar.



    Thanks