Visual Basic:具有多个“级别”的CallByName

时间:2017-05-05 16:11:44

标签: vba callbyname

我已经在这方面做了很多工作,但我仍然无法获得我的代码。

我有一个名为ALTER TRIGGER [dbo].[WO-A] ON [dbo].[WORKORDERS] AFTER UPDATE, INSERT, AS IF ((SELECT ROUTING FROM INSERTED) LIKE 'Assy' or (SELECT ROUTING FROM INSERTED) LIKE 'L&P' or (SELECT ROUTING FROM INSERTED) LIKE 'ASSY FD' or (SELECT ROUTING FROM INSERTED) LIKE 'ASSY BD' or (SELECT ROUTING FROM INSERTED) LIKE 'RGA' ) BEGIN set nocount on IF TRIGGER_NESTLEVEL() > 1 RETURN UPDATE T1 SET [Assembly Notes]=T2.[Assembly Notes], [Assy SO Confirm]=T2.[ASSEMBLY LOOKUP C], [CALC COLOR]=T2.[COLOR], [PILOT SIZE]=T2.[PILOT SIZE2], [NO OF HOLES]=T2.[BOLT HOLES2], [C/S OD]=T2.[C/S OD2], [DISC OD]=T2.[DISC OD], [C/S ANGLE2]=T2.[C/S ANGLE2], [BH SIZE2]=T2.[BH SIZE2], [SHORT WO PN]=t2.[CALC STOCK NO], [CALC OFF-SET]=T2.[CALC OFF-SET], [RUN OUT LAT]=T2.[RUN OUT LAT], [RUN OUT RAD]=T2.[RUN OUT RAD], [BOM SECONDRY DISC]=T2.[BOM - SECONDARY DISC], [BH SPEC]=T2.[BH SPEC], [BH CIRCLE2]=T2.[BH CIRCLE2], [DISC THICKNESS2]=T2.[DISC THICKNESS], [MRP BOM PARTS 1]=T2.[WHL BOM PART 1 PN], [MRP BOM PARTS 2]=T2.[WHL BOM PART 2 PN], [MRP BOM PARTS 3]=T2.[WHL BOM PART 3 PN], [MRP BOM PARTS 4]=T2.[WHL BOM PART 4 PN], --[ASSY PN-S]=T2.[CALC STOCK NO], [SHORT WO PN2]=T2.[CALC STOCK NO], [WO SALES DESCRIPTION] = T2.[Description for Sales], --[Assy SO Confirm]=T2.[Assembly Lookup C], [CUSTOMER PN]=T2.[CUSTOMER PN], [MRP Wheel]=T2.[BOM WHEEL PN], [TIRE PN]=T2.[BOM tire], [TIRE SIZE]=T2.[TIRE SIZE], [TIRE SUPPLIER]=T22.[Manufacturer], [TIRE QUANTITY]=CASE WHEN T1.[TIRE PN]!='' THEN T1.[QUANTITY] WHEN T1.[TIRE PN] IS NOT NULL THEN T1.[QUANTITY] ELSE '' END, [RIM PN (MRP)]=t2.[BOM - RIM PN], [WO Popularity]=t2.[POPULARITY], --[RIM QUANTITY]=t2.[q [WEIGHT]=T2.[unitWeight],--?? CHECK WETHER RIGHT COLUMN --[ASSY DESC FOR LABEL] SIZE=T21.[SIZE], [MRP BLK DISC]=T21.[BLK DISC PN], [WHEEL PN 1]=NULL, [WHEEL PN 1-S]=NULL, [ASSY PN-S]=NULL, [MO ASSY PN]=null FROM WORKORDERS T1 INNER JOIN inserted i ON T1.[WORK ORDER #] = i.[WORK ORDER #] CROSS APPLY (SELECT TOP 1 * FROM [ASSEMBLIES] T2 WHERE t1.[ASSY PN] = T2.[ASSEMBLY LOOKUP V 1]) T2 CROSS APPLY (SELECT TOP 1 * FROM [TIRES] T22 WHERE T22.[Tire Lookup H] = T2.[BOM Tire] ) T22 CROSS APPLY (SELECT TOP 1 * FROM [WHEELS] T21 WHERE T2.[BOM WHEEL] = T21.[WHEEL LOOKUP V] ) T21 END 的类,它有一个只读属性ContactAddress类包含AddressStreet等属性。现在我想像这样指定联系人的街道:

City

但是我收到一条错误,说“Address.Street”不是CallByName(contact, "Address.Street", CallType.Set, new_street) 的成员。

我需要通过名称来设置属性

Contact

不是一种选择。

如何让上面的第一个例子起作用?

1 个答案:

答案 0 :(得分:1)

CallByName进行一次通话。你想做两个。

首先调用getter:

Dim contactAddress As Address
Set contactAddress = CallByName(contact, "Address", CallType.Get)

然后,..那么CallByName没有理由分配Street属性值:

contactAddress.Street = new_street