Будьте добры, подскажите по написанию макроса. Имеет

Автор ForumOOo (бот), 3 февраля 2016, 16:25

0 Пользователи и 1 гость просматривают эту тему.

MasterLi

#15
Navigation from one form to another
A form is to be opened when a particular event occurs.
In the form control properties, on the line "Additional information" (tag), enter the name of the form.
Further information can also be entered here, and subsequently separated out by using the
Split() function.
SUB From_form_to_form(oEvent AS OBJECT)
DIM stTag AS String
stTag = oEvent.Source.Model.Tag
aForm() = Split(stTag, ",")
The array is declared and filled with the form names, first the form to be opened and secondly the
current form, which will be closed after the other has been opened.
ThisDatabaseDocument.FormDocuments.getByName( Trim(aForm(0)) ).open
ThisDatabaseDocument.FormDocuments.getByName( Trim(aForm(1)) ).close
END SUB
If instead, the other form is only to be opened when the current one is closed, for example where a
main form exists and all other forms are controlled from it using buttons, the following macro
should be bound to the form with Tools > Customize > Events > Document closed:
SUB Mainform_open
ThisDatabaseDocument.FormDocuments.getByName( "Mainform" ).open
END SUB
If the form documents are sorted within the ODB file into directories, the macro for changing the
form needs to be more extensive:
SUB From_form_to_form_with_folders(oEvent AS OBJECT)
REM The form to be opened is given first.
REM If a form is in a folder, use "/" to define the relationship
REM so that the subfolder can be found.
DIM stTag AS STRING
stTag = oEvent.Source.Model.Tag 'Tag is entered in the additional
information
aForms() = Split(stTag, ",") 'Here the form name for the new form comes
first, then the one for the old form
aForms1() = Split(aForms(0),"/")
aForms2() = Split(aForms(1),"/")
IF UBound(aForms1()) = 0 THEN
ThisDatabaseDocument.FormDocuments.getByName( Trim(aForms1(0)) ).open
ELSE
ThisDatabaseDocument.FormDocuments.getByName(
Trim(aForms1(0)) ).getByName( Trim(aForms1(1)) ).open
END IF
Improving usability 21
IF UBound(aForms2()) = 0 THEN
ThisDatabaseDocument.FormDocuments.getByName( Trim(aForms2(0)) ).close
ELSE
ThisDatabaseDocument.FormDocuments.getByName(
Trim(aForms2(0)) ).getByName( Trim(aForms2(1)) ).close
END IF
END SUB
Form documents that lie in a directory are entered into the Additional Information field as
directory/form. This must be converted to:
...getByName("Directory").getByName("Form").

MasterLi

Сейчас попробую вставить getByName два раза: первый раз название папки, во втором случае - название формы.