Associating a Detail Object to A Dimension

Hi All

I’m using VB to create loads of objects that I’ve got in an Excel spreadsheet. Some of the objects are detail objects and I’m trying to use the

Obj.AssociatedDimension= MyObject (MyClass) 

property to nominate the Dimension that I want the object to be linked to.

I don’t get any errors. The detail object is created in the correct class but my link to the dimension is not there. I think the way I am referring to the Dimension Object is incorrect. I’m simply supplying it with a string with the object name and the class name in brackets.

Can anyone tell me how to correctly refer to the Class/Object I’m interested in.

Thanks


Grantie :uk: (BOB member since 2004-07-01)

How are MyObject and MyClass defined? In any case, the right hand side needs to be a reference to an Object object (confusing, sorry :crazy_face: ). In the same way that you Set Obj = the detail object, if you Set Obj2 = the dimension object, then your code would be:

Obj.AssociatedDimension = Obj2

Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Thanks Dwayne. I now have something like this:


            Set Cls = Univ.Classes.FindClass('ClassName')
            Set ObjD = Cls.Objects('ObjectName')
            Obj.AssociatedDimension = ObjD

But nothing happens. I’ve tried it with SET as well. The only thing I can think of is that ObjD has just been created. Maybe I need to save the universe before doing this step?


Grantie :uk: (BOB member since 2004-07-01)

Nope I put a Save in and that didn’t make a difference.


Grantie :uk: (BOB member since 2004-07-01)

Is that the exact syntax? I’m quite certain the apostrophes need to be quote marks if those are character strings, and need to be removed if those are VBA variables. Do you get any errors (compile, runtime)?


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Sorry I’m not being helpful.

Here is the full code:


   For RowNumR = 1 To RngR.Rows.Count
         Set Cls = Univ.Classes.FindClass(RngR.Cells(RowNumR, 1).Value)
         Set Obj = Cls.Objects.Add(RngR.Cells(RowNumR, 2), Cls.Name)
         Obj.Type = dsCharacterObject
         Obj.Qualification = RngR.Cells(RowNumR, 3).Value
         Obj.Description = RngR.Cells(RowNumR, 4)
         Set ObjD = Cls.Objects(RngR.Cells(RowNumR, 5))
         MsgBox ObjD.Name
         Obj.AssociatedDimension = ObjD
         Obj.Select = RngR.Cells(RowNumR, 6)
    Next RowNumR

Thanks.


Grantie :uk: (BOB member since 2004-07-01)

If the ObjD object does indeed exist first (I assume you get no errors and the MsgBox diagnostic confirms), I’m afraid I’m out of ideas. I don’t have time to test it myself at the moment, but maybe if you let us know the version you’re using, someone else may help confirm … could possibly be a bug.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Thanks Dwayne. This does in fact work when I reference the VALUE in the Excel cell and not just the reange object. Derr. :oops:

But you pointed me in the right direction.

Cheers. :smiley:


Grantie :uk: (BOB member since 2004-07-01)

Sometimes the “nudge” is better than the answer … you learn more that way! Glad you’ve solved it.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)