Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automation Error

Status
Not open for further replies.

nnmmss

Programmer
Sep 7, 2004
123
IR
i have defined 3 varibale in Global section of my project
'************ Global **********
Public ProjectPath As New Collection
Public PInterval As New Collection
Public PrjFinish As New Collection
'************ End of Global **********

in Other form of my project named FrmMain , i have tried to fill these collection
like these
Public Sub CreateNodes()
ProjectPath.Add Item:=varCompPath, Key:=rst("PrjId"),
PrjFinish.Add Item:=rst("PrjFinish"), Key:=rst("PrjId")
PInterval.Add Item:=varInterval, Key:=rst("PrjId")
end sub

now as these variable are Global I want to use them in other procedure in that form like this

If PrjFinish.Item(i) > 0 Then
PrjPath = ProjectPath.Item(i)
If fs.FileExists(PrjPath) Then
msgbox "Do something"
End If
End If

The problem is that ProjectPath and PInterval can work fine as a Global variable but PrjFinish Gives a Automation Error and nothing else
can anybody help me?
 
A thought, try changing this line:

PrjFinish.Add Item:=rst("PrjFinish"), Key:=rst("PrjId")

with this:

PrjFinish.Add Item:=CLng(rst("PrjFinish")), Key:=rst("PrjId")

If the "PrjFinish" field isn't a number, use CStr or whatever is appropriate instead of CLng.

I think what is happening is you are storing a Field object into the collection, not the value (which I assume is what you want).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top