Access does not load in 1s. Source code of the function to create a database file

Peculiarities:

  1. The database file can be created separately from the data.
  2. A table in a database file can be created separately from the data.
  3. Data types are converted to access compatible.
  4. Values ​​equal to an empty date or string are converted to null.
  5. Non-primitive and non-string data types (reference) are truncated to 255 characters.
  6. String data types adapt to the length of the string to save space.
  7. The single quote character ' will be written to the database using the char() query function.
  8. Automatically adding a primary index (row counter).

Restrictions:

  1. Works only with a value table as a data source.
  2. The mechanism only works in thick client mode. This is due to the use of the ADO library and the value table at the same time.
  3. Work is possible only on Windows systems.

The mechanism itself consists of three blocks:

  1. Function for creating a database file.
  2. Function for creating a database table.
  3. Function for writing data to a database table.

Schematically, the mechanism looks like this:

Source code DB file creation functions:

//function creates new file DB with the ability to overwrite the old one//Parameter //Parameter 2 : boolean - rewrite flag if the database file already exists //returns 0 if the function completed successfully and not 0 if the function failed Function CreateFileAccess(ValueFileName,ValueOverwriteFile = True) //Check the validity of the file name If EmptyString(FileName) Then Return - 2 ; Otherwise //analyze where the file is on disk If OverwriteFile Then File = New File(FileName) ; If File. Exists() Then File = Undefined ; DeleteFiles(FileName) ; EndIf ; EndIf ; EndIf ; State(" The access file is created:" + FileName); //create a database shell Try ADOX = New COMObject(" ADOX . Catalog" ); Exception Report(" " + Symbols. PS + DescriptionError() ) ; EndAttempt ; //Connect to the newly created database ConnectionString = " Provider " " " + FileName + " " " " ; //connect Attempt ADOH. Create(ConnectionString) ; Exception Report(" Failed to generate data file. When creating an ADOX object. Catalog an error occurred!" + Symbols. PS + DescriptionError() ) ; Return - 1 ; EndAttempt ; ADOH. ActiveConnection. Close() ; ADOH = Undefined ; Return 0 ; EndFunction

The function receives 2 parameters:

  1. The file name of the future database is a string. This is the full path to the file; if it is not passed, the procedure will terminate.
  2. Overwrite a file - boolean. This is a boolean flag that uses a file overwrite mechanism.

First, the full file name is checked. Then the mechanism for rewriting the file works. If necessary, the existing file is deleted. After which the procedure proceeds to creating empty file DB. This is done using the ADOX.Catalog object. To understand the intricacies of how ADOX.Catalog works, I recommend looking for relevant information on the Microsoft website.

The second “gear” of the upload mechanism in access implements the creation of a table in the database file. To create tables, the same ADOX.Catalog object is used.

Source code for the procedure for creating a new table in the database:

//Parameter 1 : string - full name database file//Parameter 2: Value Table - Table with data to be uploaded//Parameter 3: structure - description of the table being created (can be generated using the function: Creation of Structure of Description of Fields) //Returns 0 if the function completed successfully and not 0 if the function failed Function EnterTableData(FileNameValue, DataTableValue, TableDescriptionValue)ConnectionString = " Provider =Microsoft. Jet. OLEDB. 4. 0 ; Data Source=" " " + FileName + " " " ; Jet OLEDB:Engine Type= 5 ;" ; Connector = New COMObject(" ADODB . Connection" ) ; Connector. ConnectionString = Connection String; //connection Attempt Connector. Open() ; Exception Report(" Failed to open database file!" ); Report(ErrorDescription() ) ; Return - 1 ; EndAttempt ; Status(" I fill out the table with data:" + TableDescription.TableName); //DB command object Com = New COMObject(" ADODB . Command" ) ;Com. ActiveConnection = Connector; //constant 1 means "query", there are also views and stored procedures Com. CommandType = 1 ; RowCounter = 1 ; For Each Line TK From Data Table Loop ProcessingUserInterrupt() ; //traversal data columns FieldList = Format(RowCounter, " CH = " ) + " , " + Symbols. PS; Row Counter = Row Counter + 1 ; Column Counter = 0 ; For Each ColumnTZ From DataTable. Columns Cycle CurrentValue = RowTK[ ColumnTZ. Name] ; Field Description = Table Description. Field Description. Get(Column Counter) ; //data type analysis If DescriptionFields. Type = " 3 " Then // integer TechValue = ? (TechValue = null , 0 , TechValue); FieldList = FieldList + Format(TechValue, " CHN = null ; CHG=" ) + " , 5 " Then //the number is fractional //convert null to 0 because the further Format() function does not convert it correctly TechValue = ? (TechValue = null , 0 , TechValue) ; FieldList = FieldList + Format(CurrentValue, " BRD = . ; CHN= null ; CHG=" ) + " , " + Symbols. PS; ElseIfField Description. Type = " 7 "Then //date CurrentValue = ? (TechValue = null , " 00010101 " , TechValue) ; If TechValue = " 00010101 " Then ModValue = " null" ; Else ModValue = " " " + Format(TechValue, " DLF = DT" ) + " " " ; EndIf ; FieldList = FieldList + ModValue + " , " + Symbols. PS; ElseIfField Description. Type = " 11 " Then //boolean TechValue = ? (TechValue = null , False , TechValue); FieldList = FieldList + Format(TechValue, " BL = false ; BI= true" ) + " , " + Symbols. PS; ElseIfField Description. Type = " 202 " Then // string TechValue = ? (TechValue = null , " " , TechValue); ; StringValue = Lev(TechValue, 255 ) ; If EmptyString(StringValue) Then FieldList = FieldList + " null" + Symbols. PS; Otherwise ModValue = StrReplace(ValueString, " " " , " " +chr() + " " ); FieldList = FieldList + " " " + Abbr(Lev(ModValue, 255 ) ) + " " , " + Symbols. PS EndIf; ElseIfField Description. Type = " 203 " Then //string If EmptyString(ValueString) Then FieldList = FieldList + " null" + Symbols. PS; Else ModValue = StrReplace(CurrentValue, " " " , " " +chr(" + SymbolCode(" " " ) + " ) + " " ); FieldList = FieldList + " " " + ModValue + " " , " + Symbols. PS EndIf; EndIf; Column Counter = Column Counter + 1; EndCycle; //cut off the last comma FieldList = Lev(FieldList, StrLength(FieldList) - 2 ) ; QueryText = "INSERT INTO" + TableDescription. TableName + " VALUES ( " +FieldList+ " ) " ; Com. CommandText = Request Text; Attempt Com. Execute () ; Exception Report (" Error writing data!" + Symbols. PS + " Request Text: " + Request Text + Symbols. PS + Error Description() ) ; Return - 2 ; EndAttempt ; EndCycle ; //close the connection Com. ActiveConnection. Close() ; Com = Undefined ; Connector = Undefined ; Return 0 ; EndFunction

The function receives 3 parameters:

  1. Table Description Structure - a structure containing a description of the table itself and its fields. It is formed by an auxiliary function, which I will provide below.
  2. Filename - string name of the database file.
  3. DeleteExistingTable - a flag that determines the behavior of the function in relation to existing tables of the same name.

Having received control, the function opens the database file. If the connection is successful, an “ADOX.Catalog” object (table catalog) is created, which first checks the existence of the table in accordance with function parameter No. 3. The next action creates new table. A key field (index) is added to the table. Next, based on function parameter No. 2, table fields of the corresponding types are created. Once complete, the newly created table is added to the catalog and the connection is closed.

Of course, manually collecting the parameter of function No. 2 is quite labor-intensive; to make it easier, I wrote a function that, based on a table of values ​​with data, forms the structure of the table description.

Source code of the function composing the field description structure:

//auxiliary function for formatting the field description structure//Parameter 1: Value Table - Table with data to be uploaded//Parameter 2: string - full table name (must not contain illegal characters: " , .) //Returns the table description structure Function ComposeFieldDescriptionStructure(DataTableValue, TableNameValue)DescriptionStructure = New Structure("TableName , DescriptionFields" ) ;DescriptionStructure.TableName =TableName;DescriptionStructure.FieldDescription = New Array; //we go through the columns of the table of values For Each Column TK From the Data Table. Columns Cycle StructurePropertyFields = New Structure(" Name , Type, Length, Synonym" ); ColumnValueType = ColumnTZ.ValueType;StringLength =ColumnValueType.StringQualifiers.Length; //checking the types contained in the column //any composite type will be a string IfColumnValueType. Types() . Quantity() > 2 Then StructurePropertyField. Name = ColumnTZ. Name; StructurePropertyFields. Type = " 202 " ; //adVarWChar, type FieldPropertyStructure. Length = 255 ;FieldPropertyStructure. Synonym = ColumnTZ. Header; ElseIfColumnValueType. ContainsType(Type(" Line" ) ) Then FieldPropertyStructure. Name = TK Column. Name; If LineLength = 0 Then FieldPropertyStructure. Type = " 203 " ; //adLongVarWChar("memo"), type 203 [Unicode text stream (DT_NTEXT)]202 " ; //adVarWChar, type 202 [255 character Unicode string (DT_WSTR)] //FieldPropertyStructure.Length = ?(LineLength 0 Then //article editor error when inserting code, could not fix it, see processing StructurePropertyFields. Type = " 5 " ; //adDouble, type 5 Otherwise StructurePropertyFields. Type = " 3 " ; //adInteger, type 3 EndIf ; ElseIfColumnValueType. ContainsType(Type(" Boolean ") ) Then StructurePropertyField. Name = ColumnTZ. Name; StructurePropertyFields. Type = " 11 " ; //adBoolean, type 11 StructurePropertyFields. Length = Undefined ; StructurePropertyFields. Synonym = ColumnTZ. Title; ElseIfColumnValueType. ContainsType(Type(" Date ") ) Then StructurePropertyField. Name = ColumnTZ. Name; StructurePropertyFields. Type = " 7 " ; //adDate, type 7 StructurePropertyFields. Length = Undefined ; StructurePropertyFields. Synonym = ColumnTZ. Title; Otherwise StructurePropertyFields. Name = ColumnTZ. Name; StructurePropertyFields. Type = " 202 " ; //adVarWChar, type 202 [255 character Unicode string (DT_WSTR)] StructurePropertyFields. Length = 255 ; StructurePropertyFields. Synonym = ColumnTZ. Title; EndIf ; StructureDescription. DescriptionFields. Add(FieldPropertyStructure) ; EndCycle ; returnDescriptionStructure; EndFunction

The function receives 2 parameters:

  1. DataTable - a table of values ​​with data. From this parameter, the function generates a description of the data types of future fields. I recommend creating this table of values ​​through a query, since in this case all fields of the technical assignment will be typed.
  2. TableName - string name future table access.

Initially, a structure is created that describes the database itself, after which an array is added that will contain other structures that describe the fields. In the process of looping through the columns of the value table, an array of field descriptions is filled. The field description structure contains 4 main properties:

  1. Name - string of the name of the future field. Must not contain spaces or incompatible characters. If you create a table of values ​​using a query, then there should be no problems, but if you fill out the table of values ​​yourself, the responsibility falls entirely on you.
  2. The type is string, it is a Microsoft constant. In our case, we only use: an integer number, a fractional number, a string (of varying lengths), a Boolean and a date.
  3. Length - number, for string types.
  4. Synonym - string, text description of the field.

Having finished forming the structure, it returns.

Finally, you can move on to the function that writes data to the database table. In this function, one might say, the core of the functionality of the entire mechanism is concentrated. Thus, this function is the most difficult, but this should not scare you. A programmer is a programmer because he develops an analytical mindset.

Source code for the function entering data into a table:

//function enters data into the table //Parameter 1 : string - full name of the database file //Parameter 2 : Value Table - Table with data to be uploaded //Parameter 3 : structure - description of the table being created (can be generated using the function: Compiling StructureDescription of Fields) //Returns 0 in case of successful completion of the work and not 0 if the function failed Function Entering Data into a Table (Meaning File name , Meaning DataTable , Meaning DescriptionTables ) Connection string = " Provider = Microsoft . Jet . OLEDB . 4 . 0 ; Data Source = " " " + File name + " " " ; Jet OLEDB:Engine Type = 5 ; " ; //object responsible for communication with the database Connector = New COMObject (" ADODB . Connection" ) ; Connector . ConnectionString = Connection string ; //connection Attempt Connector . Open () ; Exception Report (" Not managed to open the database file!" ) ; Report ( DescriptionErrors () ) ; Return - 1 ; EndAttempt; State (" I fill out the table with data:" + DescriptionTables . TableName ) ; //DB command object Com = New COMObject (" ADODB . Command" ) ; Com . ActiveConnection = Connector ; //constant 1 means "query", there are also views and stored procedures Com . CommandType = 1 ; Row Counter = 1 ; For Each Line TK From DataTable Cycle Handling User Interrupts () ; //traversal data columns List of Fields = Format ( Row Counter , " CHG = " ) + " , " + Symbols . PS ; Row Counter = Row Counter + 1 ; Column Counter = 0 ; //cycle for generating a list of fields For Each Column TK From DataTable . Columns Cycle TechValue = Line TK [ ColumnTZ . Name ] ; DescriptionFields = DescriptionTables . DescriptionFields . Get ( Column Counter ) ; //data type analysis If DescriptionFields . Type = " 3 " Then //integer List of Fields = List of Fields + Format ( TechValue , " CHN = null; CHG = " ) + " , " + Symbols . PS ; OtherwiseIf DescriptionFields . Type = " 5 " Then //fractional number List of Fields = List of Fields + Format ( TechValue , " CHRD = . ; CHN = null; CHG = " ) + " , " + Symbols . PS ; OtherwiseIf DescriptionFields . Type = " 7 " Then //date If TechValue = "00010101 " Then ModValue = " null" ; Otherwise ModValue = " " " + Format ( TechValue , " DLF = D.T." ) + " " " ; EndIf; List of Fields = List of Fields + ModValue + " , " + Symbols . PS ; OtherwiseIf DescriptionFields . Type = " 11 " Then //boolean List of Fields = List of Fields + Format ( TechValue , " BL = false; BI = true" ) + " , " + Symbols . PS ; OtherwiseIf DescriptionFields . Type = " 202 " Then //line ValueString = Lion ( TechValue , 255 ) ; If EmptyString ( ValueString ) Then List of Fields = List of Fields + " null, " + Symbols . PS ; Otherwise //Single quote is a special character in sql //convert this symbol through code ModValue = PageReplace ( ValueString , " " " , " " + chr (" + Symbol Code (" " " ) + " ) + " " ) ; List of Fields = List of Fields + " " " + AbbrLP ( Lion ( ModValue , 255 ) ) + " ", " + Symbols . PS EndIf; OtherwiseIf DescriptionFields . Type = " 203 " Then //line If EmptyString ( ValueString ) Then List of Fields = List of Fields + " null, " + Symbols . PS ; Otherwise ModValue = PageReplace ( TechValue , " " " , " " + chr (" + Symbol Code (" " " ) + " ) + " " ) ; List of Fields = List of Fields + " " " + ModValue + " ", " + Symbols . PS EndIf; EndIf; Column Counter = Column Counter + 1 ; End of the Cycle; //For Each Column TK From Data Table. Columns Cycle //cut off the last comma List of Fields = Lion ( List of Fields , StrLength ( List of Fields ) - 2 ) ; //final formation of the request test Request Text = " INSERT INTO" + DescriptionTables . TableName + " VALUES (" + List of Fields + " ) " ; Com . CommandText = Query text ; //writing data to the database (executing a query) Attempt Com . Execute() ; Exception Report (" Error writing data!" + Symbols . PS + " Request text:" + Request Text + Symbols . PS + DescriptionErrors () ) ; Return - 2 ; EndAttempt; End of the Cycle; //For Each LineTK From Data Cycle //close the connection Com . ActiveConnection . Close () ; Com = Undefined; Connector = Undefined; Return 0 ; EndFunction

The function receives 3 parameters:

  1. FileName - string name of the database file.
  2. DataTable - a table of values ​​containing data.
  3. Table Description - a structure describing the table fields and name.

To work with the database, a connection that is already familiar to us is created. Having connected, we create an object responsible for executing sql instructions. Next, we organize a loop through the rows of the table of values ​​(function parameter No. 2) and a nested loop through the columns of the table. The row counter will be used to index rows. The column counter will be used to search for a field description in the table description structure (parameter No. 3). Going through the columns of the next row, we analyze their types (according to the table description) and perform the appropriate transformations. As a result, we have a ready-made sql command for writing a line to the database. We apply the received sql instruction using the ADODB.Command object. At the end of the process, close the connections and clear the memory.

Unfortunately, on this site I was not able to attach processing for the thick client, which can upload any directories to the access database. But you can download it on Yandex disk: http://yadi.sk/d/UzK_PAsJ3vjTS. This processing involves all the parts of the universal unloading mechanism. Of course, this mechanism is not limited to this processing. It can be safely copied as in separate module, and in your processing. I do not rule out erroneous situations that could lead to upload failure, but this is not a commercial project. You are free to modify this mechanism to suit your needs. Below are 2 appendices describing adox constants. I hope this mechanism will be useful to you. I wish you success in your professional career!

Appendix 1 list of additional properties of the access table field:

AutoIncrement

Sets the field type to "Counter" with the value automatically incremented when a record is added.

Default

Default field value.

Description

Description of the field.

Fixed Length

Determines whether the field will be fixed length or variable.

Increment

The value by which the counter type field will be incremented.

Nullable

Determines whether the field can contain no value, in other words, whether the field should be required.

Seed

The value from which counting will begin in the first record for a field of type "counter".

Jet OLEDB:Allow Zero Length

Determines whether text fields can contain zero-length strings. Ignored for non-character fields.

Jet OLEDB:AutoGenerate

Determines whether a new GUID value will be automatically generated for fields of type adGUID.

Jet OLEDB:Column Validation Rule

An expression that determines the correctness of the value written in the field must be written in SQL WHERE format but without keyword WHERE.

Jet OLEDB:Column Validation Text

The text that will be displayed if the value entered in the field does not correspond to the rule defined for this field (Rule).

Jet OLEDB:Compressed UNICODE Strings

Determines whether Microsoft Jet will compress UNICODE strings when writing to disk. Ignored if the database is not in Microsoft format Jet version 4.0.

Jet OLEDB:Hyperlink

Specifies that the data in the field is a hyperlink. Ignored for fields with a type other than adLongVarWChar.

Jet OLEDB:IISAM Not Last Column

For Installable-ISAMs, this property informs the I-ISAM that there are more columns that are going to be added to the table after this one. If you are using ITableDefinition::AddColumn or ITableDefinition::CreateTable, it is required that you set this property for every.

Jet OLEDB:One BLOB per Page

Determines whether data should be stored in separate pages (True) or can use shared database pages to save disk space. Works only with adLongVarBinary fields.

Appendix 2 list of value types used in ADOX

adDouble, type 5 - fractional number

adDate, type 7 - date/time

adCurrency, type 6 - integer

adInteger, type 3 - unsigned integer

adBoolean, type 11 - boolean

adVarWChar, type 202 - unicode string 255 characters long

adLongVarWChar("memo"), type 203 - unicode string unlimited string

Recently I needed to download all the data from one simple Access database into a self-written configuration (1C:Enterprise. There wasn’t much information to transfer and, in principle, it was possible to offload this fascinating process to the user, but I decided to help my already busy employees.

The help consisted of complete automation of this process. I had to write a simple processing that did everything in a few seconds. Before this task, I didn’t have to work with the 1C + Access combination, so before I grabbed the keyboard and started spanking the code, I decided to read the manuals.

I knew from the very beginning that all interaction would involve using the appropriate providers, but I still decided to dig into the examples.

I thought for a long time in what vein to write this note. In the end, I settled on the simplest option - provide the code for my solution. Even if it is not very optimal, it is more than enough for most tasks.

So, let's start looking at everything in order. We create a new processing and throw a single component on it - “TableField”. I stretched this component across the entire form. As a result, my form looked like in Figure 1.


Figure 1. Processing form

At this point we can assume that the form design is ready. We will not create columns manually, but will perform this procedure dynamically. Fortunately, it's not difficult. Create a “On Click” event handler for the “Run” button and write the following code in it:

//Clear our table field TableField1.Clear(); TableField1.Columns.Clear(); //Preparing the connection string for MS Access //The path to the database is indicated at the very end Connection string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+"C:\mydb.mdb"; ConnectionWithBase = New COMObject("ADODB.Connection"); //Connect ConnectionWithBase.Open(ConnectionString); //Get a set of records from the table demo_tableRecords Collection = New COMObject("ADODB.Recordset"); RecordsCollection.Open("select * from demo_table", DatabaseConnection, 1); //read the structure of the table fields //In the table of values, create all the columns that are in the Access table For count = 0 by Records Collection.Fields.Count - 1 Cycle TableField1.Columns.Add("Column" + count, Row(Records Collection .Fields.Item (count).Name)); Add(); For count = 0 by RecordsCollection.Fields.Count - 1 Cycle NewRow["Column" + count] = RecordsCollection.fields(TableField1.Columns[count].Value; EndCycle.MoveNext(); End of the Cycle; //Display data from the specification in the TableFieldFormElements.TableField1.Value = TableFormElements.TableField1.CreateColumns();

The code turned out to be not too big, but quite useful. I did not make any bindings to a specific structure. The code works great on a wide variety of tables. I have nothing more to add, so I'll say goodbye

In short - no way. In everything related to interaction with government agencies (be it tax, financial statements, all sorts of excise taxes, etc.), 1C cannot be replaced by anything and trying to do this is, to say the least, unconstructive.

But don’t stop reading this article, this is not the main idea yet. The main thing is not to fall into a logical trap and consider 1C completely indispensable in any part of the automation of all processes in the enterprise. Here there is something to argue with and something to offer. I want to talk about one successful experience in automating various aspects of the business activities of a computer company and, of course, about connecting this solution with 1C. The work grew out of the need to interface a self-developed system with the 1C program, but this approach (division into 2 program blocks) can be developed into a full-fledged philosophy for building an information system in general.

Initially the task was as follows. There was corporate system automation written in Microsoft Access. Over the many years of its development, it has absorbed almost all everyday tasks - maintaining a bank, issuing invoices, preparing accounting documents for shipment, maintaining a warehouse, accounting for components serial numbers, compilation technological maps for production, etc. Recently, the following additions have been added to the system’s capabilities: creation of bank payments directly based on incoming invoices, automatic generation price lists in various formats for publication on web resources, updating the company’s website and preparing Contracts based on existing templates (so-called office automation). Plus the presence of a large amount of analytics and maintaining all management accounting. All this made the system completely irreplaceable - transferring all this functionality to 1C would have taken a lot of time and money.

On the other hand, the 1C-Enterprise program served only the needs of the accounting department for maintaining accounting and accounting records and submitting reports. Thus, 1C was “untied” from the daily functioning of the company, and the completed documents were entered into the database a posteriori.

What is good about this scheme? There are several advantages:
- exclusion of managers and other (ir)responsible persons from the “holy of holies” - the accounting database, which should be formed only by employees who have an understanding of the subject; accurate maintenance of directories,
- removal from 1C of everything that is not related to it: from management tasks that do not require reflection in accounting, to all other points that are specific to the company and to which outsiders should not have access,
- savings on licenses: 1C workstations cost significant money,
- important point: when implementing all the additional functionality described above directly “inside” 1C, there is a constant need for its improvement when product updates are released. This, of course, guarantees almost constant employment of 1C programmers, but this is a place where you can save significantly.

Well, the big minus, of course, is the need to double check all the documents and update the directories.

Actually, this was the main task - to get away from double work.

First you need to deal with all sorts of directories - first of all, this is a directory of contractors and items. The problem of directory synchronization, which so often arises in programs of this kind, has been sufficiently worked out and is understandable in implementation. However, in this case, a strong-willed decision was made not to use 2 directories with mutual synchronization, but to have one initial version - the one entered in MS Access, and simply replicate it in 1C ( feedback- this is just a mark in MS Access that this position has already been unloaded).
This approach greatly simplifies the task. For purely accounting needs, you need very few positions in such directories - and they are also included in external program so as not to violate the formulated principle. This way you can remove one more common problem- immense bloat of the reference book of used nomenclature. Below is the product group “Monitors”

Loading such horror into the 1C directory (and new monitor models appear almost every week) can be configured in such a way that they all fall into one position, since the nuances of the color of the frame around the screen and the number of pixels are completely insignificant for accounting! And, to be honest, the size of the diagonal is even more so if it differs by half an inch.

Further, in an external program, you can work out the merging of duplicate positions in directories, especially in the directory of counterparties, with much less losses, since in 1C this takes a lot of effort.

Thus, only “refined”, cleaned and brought into proper form data is uploaded to 1C. Unloading can be done with some frequency - portioning allows you to debug the work of the accounting department and avoid unnecessary work if during the day (or a longer period) something was canceled, changed, carried out again - all these things happen in the working MS Access database, and only “established” "The state of affairs is reported to 1C. Plus, this kind of unloading can be synchronized with backup operations and you can always be sure that the current state of the 1C database is correct.

It’s clear that documents arrive without automatic posting (although this could be configured). By the way, the MS Access database itself checks the availability of the necessary goods in the warehouse - for writing off for shipment (the dilemma is to make sure that the invoice can be issued current date that all the items necessary for write-off are in the warehouse - that is, purchased or produced - you need... to post the document in 1C. Apparently, you shouldn’t trust this to managers - or an accounting employee should always stand behind the manager)

Now about the implementation. 1C programs support a data exchange interface through the ADO mechanism. On the 1C side, the standard one is used software interface to create elements of directories and documents, so that the operation of this mechanism does not depend on the internal details of the 1C implementation, which may change from version to version and from update to update. On the other hand, the main development slogan was “to make maximum use of 1C capabilities where possible.” Therefore, in the final implementation of the bundle, only the name and TIN of the counterparty were loaded from MS Access - the data was “pulled up” from the Unified State Register of Legal Entities and Individual Entrepreneurs using the mechanism built into 1C (the same applies to bank details– they are updated using the BIC).

Queries were created in an external MS Access database that prepare all the necessary data for loading into 1C - take it and arrange it into documents and fields.

The unloading scheme consists of two stages. First, new positions in the directories of counterparties and items are loaded. The GUIDs assigned to 1C are returned to MS Access so that when uploading all documents at the second stage, the correct references to directories can be set. It looks like this

We believe that such an ideology of construction information systems can be taken as a basis not only in those companies where there are legacy non-1C systems, but also when organizing the work of new legal entities, since we have a lot of experience with MS Access. The advantages of this approach are described above.

In this article we will talk about setting up user access rights to 1C system objects.

In 1C 8, to control user access, a separate metadata object is used, which is called Roles.

Pay attention! This article was written to help programmers. Setting up rights in user mode using the example of 1C Accounting is discussed in.

A role defines the set of rights a user has. The role mechanism is very similar to the Windows rights mechanisms Active Directory. For each of the objects (directories, documents), the developer sets his own set of rights - read / write / add / change / ...

Set of available rights - the collection of all permissions in user roles.

If we open the Role metadata object, we can see the following picture:

The object has two tabs - Rights and Restriction Templates. Rights - main tab, Templates - tab for setting rights at the record level in 1C ( RLS). This is a very important topic, which I will try to describe in future articles.

We will only consider the tab Rights.

  • Objects— a list for which rights will be set.
  • Rights— a list of possible rights settings for setting.
  • Restricting access to data— role fields for customization

Please pay attention to the checkboxes at the bottom:

  • Set permissions for new objects— if the flag is set for the role, permissive rights will be automatically set on new metadata objects. I recommend installing it if you often forget to set permissions for new objects.
  • Set rights for details and tabular parts default— a flag, when set, details and tabular parts will inherit the rights of the owner (directory, document, etc.)
  • Independent rights of subordinate objects— if the flag is set, then the system will take into account the rights to the parent object when determining the rights to a configuration object

Permission settings for the entire configuration

If we open the Role and click on the configuration root, we will see the following settings:

More details about each rights to the entire configuration:

Get 267 video lessons on 1C for free:

  • Administration— administration information base(requires the “Data Administration” right)
  • Data administration— the right to administrative actions over data
  • Updating the Database Configuration- the right to
  • Monopoly mode— use of exclusive mode
  • Active users— view the list of active users
  • — log book
  • - launch right thin client
  • - right to launch web client
  • Fat client— right to the role of launching the thick client
  • Outer join— the right to start an external connection
  • Automation— the right to use automation
  • All functions mode— in managed application mode
  • Saving user data— permission or prohibition to save user data (settings, favorites, history). This is especially true for 1C managed forms.
  • Interactive discovery external treatments — opening external processing
  • Interactive opening of external reports— opening external reports
  • Conclusion— printing, recording and copying to the clipboard

Setting up 1C 8.2 rights to other metadata objects

For other main objects (directories, constants, documents, registers...), the set of rights for the role is quite standard:

  • Reading- reading (software)
  • Addition- adding (software)
  • Change- change (software)
  • Removal- removal (software)
  • View— view
  • Interactive addition- interactive addition
  • Editing— editing
  • Interactive deletion flag— interactive mark for deletion
  • Interactively unmark deletion— unmark for deletion
  • Interactive removal of marked— deleting marked objects
  • Line input— using line input mode
  • Interactive removal— direct deletion (shift +del)

Rights only for documents:

  • Interactive conducting— carrying out
  • Cancellation— cancellation of documents
  • Interactive conducting non-operative— holding (with standard form commands) a document in non-operational mode
  • Interactive cancellation— interactive cancellation
  • Interactive change of spent— editing the posted document. If the role's right is not set, the user cannot delete a posted document, set a deletion mark, resend it, or make it unposted. The form of such a document opens in viewing mode

P.S. If you still can’t figure out the user roles, you can order .
Video with an example of setting up rights in 1C Accounting 3.0:

Share