Can't declare a global Automation variable

mabl4367mabl4367 Member Posts: 143
Hi all!

Does anyone know why you can't declare a global variable of
Type: Automation
Subtype: Microsoft ActiveX Data Objects 2.8 Library'.Recordset

Below I have included the code of a report with notning but a global variable of this kind. It will not compile.
OBJECT Report 51086 TEST SQL SP CALL 2
{
  OBJECT-PROPERTIES
  {
    Date=11-08-18;
    Time=09:17:50;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
  }
  DATAITEMS
  {
  }
  REQUESTFORM
  {
    PROPERTIES
    {
      Width=9020;
      Height=3410;
    }
    CONTROLS
    {
    }
  }
  CODE
  {
    VAR
      lADORecordSet@1000000000 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000535-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'.Recordset";

    EVENT lADORecordSet@1000000000::WillChangeField@9(cFields@1000000003 : Integer;Fields@1000000002 : Variant;adStatus@1000000001 : Integer;pRecordset@1000000000 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000556-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'._Recordset");
    BEGIN
    END;

    EVENT lADORecordSet@1000000000::FieldChangeComplete@10(cFields@1000000004 : Integer;Fields@1000000003 : Variant;pError@1000000002 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000500-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'.Error";adStatus@1000000001 : Integer;pRecordset@1000000000 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000556-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'._Recordset");
    BEGIN
    END;

    EVENT lADORecordSet@1000000000::WillChangeRecord@11(adReason@1000000003 : Integer;cRecords@1000000002 : Integer;adStatus@1000000001 : Integer;pRecordset@1000000000 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000556-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'._Recordset");
    BEGIN
    END;

    EVENT lADORecordSet@1000000000::RecordChangeComplete@12(adReason@1000000004 : Integer;cRecords@1000000003 : Integer;pError@1000000002 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000500-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'.Error";adStatus@1000000001 : Integer;pRecordset@1000000000 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000556-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'._Recordset");
    BEGIN
    END;

    EVENT lADORecordSet@1000000000::WillChangeRecordset@13(adReason@1000000002 : Integer;adStatus@1000000001 : Integer;pRecordset@1000000000 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000556-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'._Recordset");
    BEGIN
    END;

    EVENT lADORecordSet@1000000000::RecordsetChangeComplete@14(adReason@1000000003 : Integer;pError@1000000002 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000500-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'.Error";adStatus@1000000001 : Integer;pRecordset@1000000000 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000556-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'._Recordset");
    BEGIN
    END;

    EVENT lADORecordSet@1000000000::WillMove@15(adReason@1000000002 : Integer;adStatus@1000000001 : Integer;pRecordset@1000000000 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000556-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'._Recordset");
    BEGIN
    END;

    EVENT lADORecordSet@1000000000::MoveComplete@16(adReason@1000000003 : Integer;pError@1000000002 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000500-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'.Error";adStatus@1000000001 : Integer;pRecordset@1000000000 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000556-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'._Recordset");
    BEGIN
    END;

    EVENT lADORecordSet@1000000000::EndOfRecordset@17(VAR fMoreData@1000000002 : Boolean;adStatus@1000000001 : Integer;pRecordset@1000000000 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000556-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'._Recordset");
    BEGIN
    END;

    EVENT lADORecordSet@1000000000::FetchProgress@18(Progress@1000000003 : Integer;MaxProgress@1000000002 : Integer;adStatus@1000000001 : Integer;pRecordset@1000000000 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000556-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'._Recordset");
    BEGIN
    END;

    EVENT lADORecordSet@1000000000::FetchComplete@19(pError@1000000002 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000500-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'.Error";adStatus@1000000001 : Integer;pRecordset@1000000000 : Automation "{2A75196C-D9EB-4129-B803-931327F72D5C} 2.8:{00000556-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.8 Library'._Recordset");
    BEGIN
    END;

    BEGIN
    END.
  }
}

When compiling I get the folowing message:
"The variable LADORECORDSET::WILLCHANGERECOR is defined more then once.
An example could be: 'File' exists as both a data type and a global variable"

How do I get around this problem?

Comments

  • meto89meto89 Member Posts: 10
    If you declare the variable, set the WithEvents property to no. :lol:

    I guess it's cause of the max. available chars for a function. Because of that, the names of those functions aren't unique. => ERROR.

    The same happens for example, if you declare an excel.application automation with events...

    Edit: A possible way around it is, to shorten your variable name. Back to my excel example: If my excel automation varaible has more than two chars i get the same error. Two or less chars are fine though.
  • AdministratorAdministrator Member, Moderator, Administrator Posts: 2,499
    [Topic moved from 'NAV Tips & Tricks' to 'NAV/Navision Classic Client' forum]
  • mabl4367mabl4367 Member Posts: 143
    Thanks for the tips!

    I also found another way around that seams to work.

    I made local versions of my automation variable wherever I need it. Whenever I update the value of one of the local variables, I copy it to a global variable of type variant. Before using any of my local automation variables I first copy the global variant to the local Automation before using it.
Sign In or Register to comment.