25 May 2018

Access - Visibilità di una classe referenziata

Creo un file di Access ("Library.accdb") che viene referenziato da un altro file di Access ("FrontEnd.accdb").
Se creo una classe nella Library, non si vede nel FrontEnd.

  1. Dall'editor di VBA:
    • File / Esporta File (CTRL-E)
  2. Apri il file con un editor di testo
    • modificare gli attributi VB_Creatable e VB_Exposed da False a True:
      Attribute VB_Name = "MyClass1"
      Attribute VB_GlobalNameSpace = False
      Attribute VB_Creatable = True
      Attribute VB_PredeclaredId = False
      Attribute VB_Exposed = True
      
    • Salva il file
  3. In Access:
    • rimuovi la classe
    • crea una nuova classe vuota
    • seleziona tutto il codice e cancellalo
    • dal menu: Inserisci / File e scegliere il file modificato (ATTENZIONE: se si passa da "File / Importa" gli Attributi vengono resettati!!)
    • rimuovere questo codice VB:
    • VERSION 1.0 CLASS
      BEGIN
        MultiUse = -1  'True
      End
      

16 May 2018

Pass A User-Defined Table to a Stored Procedure

/* Create a table type. */
CREATE TYPE MyTableType AS TABLE 
( Column1 VARCHAR(50)
, ........ );
GO

/* Create a procedure to receive data for the table-valued parameter. */
CREATE PROCEDURE dbo. ValidateInputXML
    @TVP MyTableType READONLY
    AS 
     -- Do what ever you want to do with the table received from caller
    GO

/* Declare a variable that references the type. */
DECLARE @myTable AS MyTableType;

-- Fill @myTable with data and send it to SP. 
insert into @myTable SELECT * FROM @tmpInput TI WHERE TI.EntryType = 'Attribute';


/* Pass the table variable data to a stored procedure. */
EXEC ValidateInputXML @myTable ;
GO


https://stackoverflow.com/questions/30515297/pass-a-user-defined-table-to-a-stored-procedure