21
MS Access objekts “Form” A Form object is a member of the Forms collection, which is a collection of all currently open forms. Within the Forms collection, individual forms are indexed beginning with zero. You can refer to an individual Form object in the Forms collection either by referring to the form by name, or by referring to its index within the collection. Syntax Example Forms!formname Forms!OrderForm Forms![form name] Forms![Order Form] Forms("formname ") Forms("OrderForm") Forms(index) Forms(0) Each Form object has a Controls collection, which contains all controls on the form. You can refer to a control on a form either by implicitly or explicitly referring to the Controls collection. Your code will be faster if you refer to the Controls collection implicitly. The following examples show two of the ways you might refer to a control named Datu_elements_1 on the form called Forma_1: Netieša formas datu vienības norādīšana Forms!Forma_1!Datu_elements_1 Tieša formas datu vienības norādīšana Forms!Forma_1.Controls!Datu_elements_1 The next two examples show how you might refer to a control named Datu_elements_2 on a subform Pak_Forma_1 contained in the form called Galv_Forma_1: Forms!Galv_Forma_1.Pak_Forma_1.Form!Controls.Datu_elements_2 Forms!Galv_Forma_1.Pak_Forma_1!Datu_elements_2 Jaunas formas izveidošana: Sub NewForm() Dim frm As Form ' Radīt formu Set frm = CreateForm ' Norādīt formas īpašību vērtības With frm .RecordSource = "Darbinieki" 1

MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

MS Access objekts “Form”

A Form object is a member of the Forms collection, which is a collection of all currently open forms. Within the Forms collection, individual forms are indexed beginning with zero. You can refer to an individual Form object in the Forms collection either by referring to the form by name, or by referring to its index within the collection.

Syntax Example

Forms!formname Forms!OrderForm

Forms![form name] Forms![Order Form]

Forms("formname") Forms("OrderForm")

Forms(index) Forms(0)

Each Form object has a Controls collection, which contains all controls on the form. You can refer to a control on a form either by implicitly or explicitly referring to the Controls collection. Your code will be faster if you refer to the Controls collection implicitly. The following examples show two of the ways you might refer to a control named Datu_elements_1 on the form called Forma_1:Netieša formas datu vienības norādīšanaForms!Forma_1!Datu_elements_1Tieša formas datu vienības norādīšanaForms!Forma_1.Controls!Datu_elements_1

The next two examples show how you might refer to a control named Datu_elements_2 on a subform Pak_Forma_1 contained in the form called Galv_Forma_1:Forms!Galv_Forma_1.Pak_Forma_1.Form!Controls.Datu_elements_2Forms!Galv_Forma_1.Pak_Forma_1!Datu_elements_2

Jaunas formas izveidošana:Sub NewForm()    Dim frm As Form    ' Radīt formu    Set frm = CreateForm    ' Norādīt formas īpašību vērtības    With frm        .RecordSource = "Darbinieki"        .Caption = "Forma_1"        .ScrollBars = 0        .NavigationButtons = True    End With    ' Atjaunot (restore) formu    DoCmd.RestoreEnd SubThe following example uses the Forms collection in an expression. If you have a form called Orders with a control named ShipCountry, you can use the IIf function to return a value based on the current value of the control. If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's contents. Enter the following expression in the ControlSource property of a text box on a form:

= IIf(IsNull(Forms!Orders! ShipCountry), "", Forms!Orders!ShipCountry)

MS Access objekts “Control”

1

Page 2: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

The Control object represents a control on a form, report, or section, within another control, or attached to another control. All controls on a form or report belong to the Controls collection for that Form or Report object. Controls within a particular section belong to the Controls collection for that section. Controls within a tab control or option group control belong to the Controls collection for that control. A label control that is attached to another control belongs to the Controls collection for that control.When you refer to an individual Control object in the Controls collection, you can refer to the Controls collection either implicitly or explicitly.' Implicitly refer to NewData control in Controls collection.Me!NewData' Use if control name contains space.Me![New Data]' Performance slightly slower.Me("NewData")' Refer to a control by its index in the controls collection.Me(0)' Refer to a NewData control by using the subform Controls collection.Me.ctlSubForm.Controls!NewData' Explicitly refer to the NewData control in the Controls collection.Me.Controls!NewDataMe.Controls("NewData")Me.Controls(0)To determine the type of an existing control, you can use the ControlType property. However, you don't need to know the specific type of a control in order to use it in code. You can simply represent it with a variable of data type Control.Dim txt As TextBoxSet txt = Forms!Employees!LastNameThe following example enumerates all the controls in the Controls collection of a form. The procedure is called from a form module and the Me keyword is used to pass the Form object to the procedure. The procedure sets certain properties if the control is a text box.' Call SetTextBoxProperties procedure.SetTextBoxProperties Me

Sub SetTextBoxProperties(frm As Form)    Dim ctl As Control    ' Enumerate Controls collection.    For Each ctl In frm.Controls        ' Check to see if control is text box.        If ctl.ControlType = acTextBox Then            ' Set control properties.            With ctl                .SetFocus                .Enabled = True                .Height = 400                .SpecialEffect = 0            End With        End If    Next ctlEnd Sub

MS Access objekts “DoCmd”

2

Page 3: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

Ycan use the methods of the DoCmd object to run Microsoft Access actions from Visual Basic. An action performs tasks such as closing windows, opening forms, and setting the value of controls.

[application.]DoCmd.method [arg1, arg2, ...]The DoCmd object has the following arguments.

Argument Description

application Optional. The Application object.

method One of the methods supported by this object.

arg1, arg2, ... The arguments for the selected method. These arguments are the same as the action arguments for the corresponding action.

Most of the methods of the DoCmd object have arguments — some are required, while others are optional. If you omit optional arguments, the arguments assume the default values for the particular method. For example, the OpenForm method uses seven arguments, but only the first argument, formname, is required. The following example shows how you can open the Employees form in the current database. Only employees with the title Sales Representative are included.DoCmd.OpenForm "Employees", , ,"[Title] = 'Sales Representative'"The DoCmd object doesn't support methods corresponding to the following actions:

1. AddMenu.2. MsgBox. Use the MsgBox function.3. RunApp. Use the Shell function to run another application.4. RunCode. Run the function directly in Visual Basic.5. SendKeys. Use the SendKeys statement.6. SetValue. Set the value directly in Visual Basic.7. StopAllMacros.8. StopMacro.

The following example opens a form in Form view and moves to a new record.

Sub ShowNewRecord()    DoCmd.OpenForm "Employees", acNormal    DoCmd.GoToRecord , , acNewRecEnd Sub

3

Page 4: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

MS Access objektu īpašību kolekcija (Properties Collection)                                    The Properties collection contains all of the built-in properties in an instance of an open Form, Report, or Control object. These properties uniquely characterize that instance of the object.Use the Properties collection in Visual Basic or in an expression to refer to form, report, or control properties on forms or reports that are currently open.Tip   The For Each...Next statement is useful for enumerating a collection.You can use the Properties collection of an object to enumerate the object's built-in properties. You don't need to know beforehand exactly which properties exist or what their characteristics (Name and Value properties) are to manipulate them.Note   In addition to the built-in properties, you can also create and add your own user-defined properties. To add a user-defined property to an existing instance of an object, see the AccessObjectProperties collection and Add method topics.The next example enumerates the Forms collection and prints the name of each open form in the Forms collection. It then enumerates the Properties collection of each form and prints the name of each property and value.

Sub AllOpenForms() Dim frm As Form, prp As Property ' Enumerate Forms collection. For Each frm In Forms ' Print name of form. Debug.Print frm.Name ' Enumerate Properties collection of each form. For Each prp In frm.Properties ' Print name of each property. Debug.Print prp.Name; " = "; prp.Value Next prp Next frmEnd Sub

4

Page 5: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

MS Access metode “ApplyFilter”                  The ApplyFilter method carries out the ApplyFilter action:

DoCmd.ApplyFilter [filtername][, wherecondition][, filtertype]The ApplyFilter method has the following arguments.

Argument Description

filtername A string expression that's the valid name of a filter or query in the current database.

  Note   When using this method to apply a server filter, the filtername argument must be blank.

wherecondition A string expression that's a valid SQL WHERE clause without the word WHERE.

filtertype One of the following intrinsic constants:

  acFilterNormal (default)acServerFilter

The filter and WHERE condition you apply become the setting of the form's or report's Filter or ServerFilter property.You must include at least one of the two ApplyFilter method arguments. If you enter a value for both arguments, the wherecondition argument is applied to the filter.The maximum length of the wherecondition argument is 32,768 characters (unlike the Where Condition action argument in the Macro window, whose maximum length is 256 characters).If you specify the wherecondition argument and leave the filtername argument blank, you must include the filtername argument's comma.The following example uses the ApplyFilter method to display only records that contain the name King in the LastName field:DoCmd.ApplyFilter , "LastName = 'King'"

MS Access metode “Beep”                  The Beep method carries out the Beep action:DoCmd.BeepThis method has no arguments.

5

Page 6: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

FindRecord Method                  The FindRecord method carries out the FindRecord action in Visual Basic. For more information on how the action and its arguments work, see the action topic.DoCmd.FindRecord findwhat[, match][, matchcase][, search][, searchasformatted][, onlycurrentfield][, findfirst]

Argument Description

findwhat An expression that evaluates to text, a number, or a date. The expression contains the data to search for.

match One of the following intrinsic constants:

  acAnywhereacEntire (default)acStart

  If you leave this argument blank, the default constant (acEntire) is assumed.

matchcase Use True (–1) for a case-sensitive search and False (0) for a search that's not case-sensitive. If you leave this argument blank, the default (False) is assumed.

search One of the following intrinsic constants:

  acDownacSearchAll (default)acUp

  If you leave this argument blank, the default constant (acSearchAll) is assumed.

searchasformatted Use True to search for data as it's formatted and False to search for data as it's stored in the database. If you leave this argument blank, the default (False) is assumed.

onlycurrentfield One of the following intrinsic constants:

  acAllacCurrent (default)

  If you leave this argument blank, the default constant (acCurrent) is assumed.

findfirst Use True to start the search at the first record. Use False to start the search at the record following the current record. If you leave this argument blank, the default (True) is assumed.

You can leave an optional argument blank in the middle of the syntax, but you must include the argument's comma. If you leave one or more trailing arguments blank, don't use a comma following the last argument you specify.The following example finds the first occurrence in the records of the name Smith in the current field. It doesn't find occurrences of smith or Smithson.DoCmd.FindRecord "Smith",, True,, TrueGoToControl Method                  The GoToControl method carries out the GoToControl action in Visual Basic. For more information on how the action and its argument work, see the action topic.DoCmd.GoToControl controlname

6

Page 7: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

Argument Description

controlname A string expression that's the name of a control on the active form or datasheet.

Use only the name of the control for the controlname argument, not the full syntax.You can also use a variable declared as a Control data type for this argument.Dim ctl As ControlSet ctl = Forms!Form1!Field3DoCmd.GoToControl ctl.NameYou can also use the SetFocus method to move the focus to a control on a form or any of its subforms, or to a field in an open table, query, or form datasheet. This is the preferred method for moving the focus in Visual Basic, especially to controls on subforms and nested subforms, because you can use the full syntax to specify the control you want to move to.The following example uses the GoToControl method to move the focus to the EmployeeID field:DoCmd.GoToControl "EmployeeID"

GoToRecord Method                  The GoToRecord method carries out the GoToRecord action in Visual Basic. For more information on how the action and its arguments work, see the action topic.DoCmd.GoToRecord [objecttype, objectname][, record][, offset]

Argument Description

objecttype One of the following intrinsic constants:

  acActiveDataObject (default)acDataFormacDataQueryacDataTable

objectname A string expression that's the valid name of an object of the type selected by the objecttype argument.

record One of the following intrinsic constants:

  acFirstacGoToacLastacNewRecacNext (default)acPrevious

  If you leave this argument blank, the default constant (acNext) is assumed.

offset A numeric expression that represents the number of records to move forward or backward if you specify acNext or acPrevious for the record argument, or the record to move to if you specify acGoTo for the record argument. The expression must result in a valid record number.

If you leave the objecttype and objectname arguments blank (the default constant, acActiveDataObject, is assumed for objecttype), the active object is assumed.You can leave an optional argument blank in the middle of the syntax, but you must include the argument's comma. If you leave one or more trailing arguments blank, don't use a comma following the last argument you specify.The following example uses the GoToRecord method to make the seventh record in the form Employees current:

7

Page 8: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

DoCmd.GoToRecord acDataForm, "Employees", acGoTo, 7

Maximize Method                  The Maximize method carries out the Maximize action in Visual Basic. For more information on how the action works, see the action topic.Note   This method cannot be applied to module windows in the Visual Basic Editor (VBE). For information about how to affect module windows see the WindowState property topic.

DoCmd.MaximizeThis method has no arguments.

Minimize Method                  The Minimize method carries out the Minimize action in Visual Basic. For more information on how the action works, see the action topic.Note   This method cannot be applied to module windows in the Visual Basic Editor (VBE). For information about how to affect module windows see the WindowState property topic.

DoCmd.MinimizeThis method has no arguments.

8

Page 9: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

OpenForm Method                  The OpenForm method carries out the OpenForm action in Visual Basic. For more information on how the action and its arguments work, see the action topic.

DoCmd.OpenForm formname[, view][, filtername][, wherecondition][, datamode][, windowmode][, openargs]

Argument Description

formname A string expression that's the valid name of a form in the current database.

  If you execute Visual Basic code containing the OpenForm method in a library database, Microsoft Access looks for the form with this name first in the library database, then in the current database.

view One of the following intrinsic constants:

  acDesignacFormDSacNormal (default)acPreview

  acNormal opens the form in Form view.

  If you leave this argument blank, the default constant (acNormal) is assumed.

filtername A string expression that's the valid name of a query in the current database.

wherecondition A string expression that's a valid SQL WHERE clause without the word WHERE.

datamode One of the following intrinsic constants:

  acFormAddacFormEditacFormPropertySettings (default)acFormReadOnly

  If you leave this argument blank (the default constant, acFormPropertySettings, is assumed), Microsoft Access opens the form in the data mode set by the form's AllowEdits, AllowDeletions, AllowAdditions, and DataEntry properties.

windowmode One of the following intrinsic constants:

  acDialogacHiddenacIconacWindowNormal (default)

  If you leave this argument blank, the default constant(acWindowNormal) is assumed.

openargs A string expression. This expression is used to set the form's OpenArgs property. This setting can then be used by code in a form module, such as the Open event procedure. The OpenArgs property can also be referred to in macros and expressions.

  For example, suppose that the form you open is a continuous-form list of clients. If you want the focus to move to a specific client record when the

9

Page 10: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

form opens, you can specify the client name with the openargs argument, and then use the FindRecord method to move the focus to the record for the client with the specified name.

  This argument is available only in Visual Basic.

The maximum length of the wherecondition argument is 32,768 characters (unlike the Where Condition action argument in the Macro window, whose maximum length is 256 characters).You can leave an optional argument blank in the middle of the syntax, but you must include the argument's comma. If you leave a trailing argument blank, don't use a comma following the last argument you specify.The following example opens the Employees form in Form view and displays only records with King in the LastName field. The displayed records can be edited, and new records can be added.DoCmd.OpenForm "Employees", , ,"LastName = 'King'"

OpenQuery Method                  The OpenQuery method carries out the OpenQuery action in Visual Basic. For more information on how the action and its arguments work, see the action topic.Note   This method is only available in the Microsoft Access database environment (.mdb). See the OpenView or OpenStoredProcedure methods if using the Microsoft Access Project environment (.adp).DoCmd.OpenQuery queryname[, view][, datamode]

Argument Description

queryname A string expression that's the valid name of a query in the current database.

  If you execute Visual Basic code containing the OpenQuery method in a library database, Microsoft Access looks for the query with this name first in the library database, then in the current database.

view One of the following intrinsic constants:

  acViewDesignacViewNormal (default)acViewPreview

  If the queryname argument is the name of a select, crosstab, union, or pass-through query whose ReturnsRecords property is set to –1, acViewNormal displays the query's result set. If the queryname argument refers to an action, data-definition, or pass-through query whose ReturnsRecords property is set to 0, acViewNormal runs the query.

  If you leave this argument blank, the default constant (acViewNormal) is assumed.

datamode One of the following intrinsic constants:

  acAddacEdit (default)acReadOnly

  If you leave this argument blank, the default constant (acEdit) is assumed.

10

Page 11: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

If you specify the datamode argument and leave the view argument blank, you must include the view argument's comma. If you leave a trailing argument blank, don't use a comma following the last argument you specify.The following example opens Sales Totals Query in Datasheet view and enables the user to view but not to edit or add records:DoCmd.OpenQuery "Sales Totals Query", , acReadOnly

Recalc Method                  The Recalc method immediately updates all calculated controls on a form.form.RecalcThe Recalc method has the following argument.

Argument Description

form A Form object representing the form that contains the controls for which you want to recalculate the values.

Using this method is equivalent to pressing the F9 key when a form has the focus. You can use this method to recalculate the values of controls that depend on other fields for which the contents may have changed.The following example uses the Recalc method to update controls on an Orders form. This form includes the Freight text box, which displays the freight cost, and a calculated control that displays the total cost of an order including freight. If the statement containing the Recalc method is placed in the AfterUpdate event procedure for the Freight text box, the total cost of an order is recalculated every time a new freight amount is entered.Sub Freight_AfterUpdate()    Me.RecalcEnd Sub

Refresh Method                  The Refresh method immediately updates the records in the underlying record source for a specified form or datasheet to reflect changes made to the data by you and other users in a multiuser environment.form.Refresh

Argument Description

form A Form object that represents the form to refresh.

Using the Refresh method is equivalent to clicking Refresh on the Records menu.Microsoft Access refreshes records automatically, based on the Refresh Interval setting on the Advanced tab of the Options dialog box, available by clicking Options on the Tools menu. ODBC data sources are refreshed based on the ODBC Refresh Interval setting on the Advanced tab of the Options dialog box. You can use the Refresh method to view changes that have been made to the current set of records in a form or datasheet since the record source underlying the form or datasheet was last refreshed.The Refresh method shows only changes made to records in the current set. Since the Refresh method doesn't actually requery the database, the current set won't include records that have been added or exclude records that have been deleted since the database was last requeried. Nor will it exclude records that no longer satisfy the criteria of the query or filter. To requery the database, use

11

Page 12: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

the Requery method. When the record source for a form is requeried, the current set of records will accurately reflect all data in the record source.Notes

1. It's often faster to refresh a form or datasheet than to requery it. This is especially true if the initial query was slow to run.

2. Don't confuse the Refresh method with the Repaint method, which repaints the screen with any pending visual changes.

The following example uses the Refresh method to update the records in the underlying record source for the form Customers whenever the form receives the focus:Private Sub Form_Activate()    Me.RefreshEnd Sub

Repaint Method                  The Repaint method completes any pending screen updates for a specified form. When performed on a form, the Repaint method also completes any pending recalculations of the form's controls.

form.RepaintArgument Description

form A Form object that represents the form to repaint.

Microsoft Access sometimes waits to complete pending screen updates until it finishes other tasks. With the Repaint method, you can force immediate repainting of the controls on the specified form. You can use the Repaint method:

1. When you change values in a number of fields. Unless you force a repaint, Microsoft Access might not display the changes immediately, especially if other fields, such as those in an expression in a calculated control, depend on values in the changed fields.

2. When you want to make sure that a form displays data in all of its fields. For example, fields containing OLE objects often don't display their data immediately after you open a form.

3. This method doesn't cause a requery of the database, nor does it show new or changed records in the form's underlying record source. You can use the Requery method to requery the source of data for the form or one of its controls.

4. Notes 5. Don't confuse the Repaint method with the Refresh method, or with the Refresh command

on the Records menu. The Refresh method and Refresh command show changes you or other users have made to the underlying record source for any of the currently displayed records in forms and datasheets. The Repaint method simply updates the screen when repainting has been delayed while Microsoft Access completes other tasks.

6. The Repaint method differs from the Echo method in that the Repaint method forces a single immediate repaint, while the Echo method turns repainting on or off.

The following example uses the Repaint method to repaint a form when the form receives the focus:Private Sub Form_Activate()    Me.RepaintEnd Sub

RunSQL Method                 

12

Page 13: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

The RunSQL method carries out the RunSQL action in Visual Basic in action queries. For more information on how the action and its arguments work, see the action topic.This method only applies to Microsoft Access databases (.mdb).DoCmd.RunSQL sqlstatement[, usetransaction]

Argument Description

sqlstatement A string expression that's a valid SQL statement for an action query or a data-definition query. It uses an INSERT INTO, DELETE, SELECT...INTO, UPDATE, CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, or DROP INDEX statement. Include an IN clause if you want to access another database.

usetransaction Use True (–1) to include this query in a transaction. Use False (0) if you don't want to use a transaction. If you leave this argument blank, the default (True) is assumed.

The maximum length of the sqlstatement argument is 32,768 characters (unlike the SQL Statement action argument in the Macro window, whose maximum length is 256 characters).If you leave the usetransaction argument blank, don't use a comma following the sqlstatement argument.The following example updates the Employees table, changing each sales manager's title to Regional Sales Manager:DoCmd.RunSQL "UPDATE Employees " & _    "SET Employees.Title = 'Regional Sales Manager' " & _    "WHERE Employees.Title = 'Sales Manager';"

SetFocus Method                  The SetFocus method moves the focus to the specified form, the specified control on the active form, or the specified field on the active datasheet.object.SetFocus

Argument Description

object A Form object that represents a form, or a Control object that represents a control on the active form or datasheet.

You can use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object.In order to read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.Other properties can be set only when a control doesn't have the focus. For example, you can't set a control's Visible or Enabled properties to False (0) when that control has the focus.You can also use the SetFocus method to navigate in a form according to certain conditions. For example, if the user selects Not applicable for the first of a set of questions on a form that's a questionnaire, your Visual Basic code might then automatically skip the questions in that set and move the focus to the first control in the next set of questions.You can move the focus only to a visible control or form. A form and controls on a form aren't visible until the form's Load event has finished. Therefore, if you use the SetFocus method in a form's Load event to move the focus to that form, you must use the Repaint method before the SetFocus method.You can't move the focus to a control if its Enabled property is set to False. You must set a control's Enabled property to True (–1) before you can move the focus to that control. You can, however, move the focus to a control if its Locked property is set to True.

13

Page 14: MS Access objekts “Form”€¦  · Web view05.03.2013  · If the value of ShipCountry is Null, the expression returns a zero-length string; otherwise, it returns the field's

If a form contains controls for which the Enabled property is set to True, you can't move the focus to the form itself. You can only move the focus to controls on the form. In this case, if you try to use SetFocus to move the focus to a form, the focus is set to the control on the form that last received the focus.Tip   You can use the SetFocus method to move the focus to a subform, which is a type of control. You can also move the focus to a control on a subform by using the SetFocus method twice, moving the focus first to the subform and then to the control on the subform.The following example uses the SetFocus method to move the focus to an EmployeeID text box on an Employees form:Forms!Employees!EmployeeID.SetFocus

SetWarnings Method                  The SetWarnings method carries out the SetWarnings action in Visual Basic. For more information on how the action and its argument work, see the action topic.DoCmd.SetWarnings warningson

Argument Description

warningson Use True (–1) to turn on the display of system messages and False (0) to turn it off.

RemarksIf you turn the display of system messages off in Visual Basic, you must turn it back on, or it will remain off, even if the user presses CTRL+BREAK or Visual Basic encounters a breakpoint. You may want to create a macro that turns the display of system messages on and then assign that macro to a key combination or a custom menu command. You could then use the key combination or menu command to turn the display of system messages on if it has been turned off in Visual Basic.The following example turns the display of system messages off:DoCmd.SetWarnings False

ShowAllRecords Method                  The ShowAllRecords method carries out the ShowAllRecords action in Visual Basic. Note   This method only applies to tables, queries, and forms within a Microsoft database (.mdb).

DoCmd.ShowAllRecordsThis method has no arguments.

14