Table of contents
TOC
Réduire la table des matières
Développer la table des matières

Form, objet (Access)Form Object (Access)

office 365 dev account|Dernière mise à jour: 14/03/2018
|
2 Collaborateurs

Un objet Form fait référence à un formulaire Microsoft Access particulier.A Form object refers to a particular Microsoft Access form.

RemarquesRemarks

Un objet Form est membre de la collection Forms, qui contient tous les formulaires actuellement ouverts.A Form object is a member of the Forms collection, which is a collection of all currently open forms.Dans la collection Forms, des formulaires individuels sont indexés à partir de zéro.Within the Forms collection, individual forms are indexed beginning with zero.Vous pouvez faire référence à un objet Form individuel dans la collection Forms par son nom ou par son index dans la collection.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. If you want to refer to a specific form in the Forms collection, it's better to refer to the form by name because a form's collection index may change.Pour faire référence à un formulaire spécifique de la collection Forms, utilisez plutôt son nom car l’index de la collection d’un formulaire peut changer.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. If you want to refer to a specific form in the Forms collection, it's better to refer to the form by name because a form's collection index may change.Si le nom du formulaire inclut un espace, le nom doit être entouré par des crochets ([ ]).If the form name includes a space, the name must be surrounded by brackets ([ ]).

SyntaxeSyntaxExempleExample
AllForms !AllForms !nomformulaireFormNameAllForms!FormulaireCommandeAllForms!OrderForm
AllForms ![nom formulaire]AllForms ![ form name]AllForms![Formulaire Commande]AllForms![Order Form]
AllForms ("nomformulaire")AllForms (" formname")AllForms("FormulaireCommande")AllForms("OrderForm")
AllForms (nomformulaire)AllForms ( formname)AllForms(0)AllForms(0)

Chaque objet Form possède une collection Controls qui contient tous les contrôles sur le formulaire.Each Form object has a Controls collection, which contains all controls on the form.Vous pouvez faire référence à un contrôle sur le formulaire en faisant référence de manière implicite ou explicite à la collection Controls.You can refer to a control on a form either by implicitly or explicitly referring to the Controls collection.Votre code sera plus rapide si vous faites référence à la collection Controls de manière implicite.Your code will be faster if you refer to the Controls collection implicitly.Les exemples suivants illustrent deux façons de faire référence à un contrôle nommé NewData sur le formulaire appelé OrderForm :The next two examples show how you might refer to a control named NewData on a subform ctlSubForm contained in the form called OrderForm:

 ' Implicit reference. 
Forms!OrderForm!NewData
' Explicit reference. 
Forms!OrderForm.Controls!NewData

Les deux exemples suivants montrent comment faire référence à un contrôle nommé NewData sur un sous-formulaire ctlSubForm contenu dans le formulaire nommé OrderForm :The next two examples show how you might refer to a control named NewData on a subform ctlSubFormctlSubForm contained in the form called OrderForm:

Forms!OrderForm.ctlSubForm.Form!Controls.NewData
Forms!OrderForm.ctlSubForm!NewData

Liens fournis par :Icône de membre de la communauté Luke Chung, FMS, Inc.Links provided by:Community Member Icon Luke Chung, FMS, Inc.

ExempleExample

L’exemple suivant montre comment utiliser les contrôles TextBox pour renseigner les critères de date d’une requête.The following example shows how to use TextBox controls to supply date criteria for a query.

Les membres UtterAccess peuvent télécharger une base de données qui contient cet exemple ici.UtterAccess members can download a database that contains this example from here.

Exemples de code fourni par :Icône de membre de la communauté la communauté UtterAccessSample code provided by:Community Member Icon The UtterAccess community

Private Sub cmdSearch_Click()

   Dim db As DAO.Database
   Dim qd As QueryDef
   Dim vWhere As Variant

   Set db = CurrentDb()

   On Error Resume Next
   db.QueryDefs.Delete "Query1"
   On Error GoTo 0

   vWhere = Null

   vWhere = vWhere & " AND [PayeeID]=" + Me.cboPayeeID

   If Nz(Me.txtEndDate, "") <> "" And Nz(Me.txtStartDate, "") <> "" Then
      vWhere = vWhere &amp; " AND [RefundProcessed] Between #" &amp; _
      Me.txtStartDate &amp; "# AND #" &amp; Me.txtEndDate &amp; "#"
   Else
      If Nz(Me.txtEndDate, "") = "" And Nz(Me.txtStartDate, "") <> "" Then
         vWhere = vWhere &amp; " AND [RefundProcessed]>=#" _
                  + Me.txtStartDate &amp; "#"
      Else
         If Nz(Me.txtEndDate, "") <> "" And Nz(Me.txtStartDate, "") = "" Then
            vWhere = vWhere &amp; " AND [RefundProcessed] <=#" _
                     + Me.txtEndDate &amp; "#"
      End If
     End If
   End If

   If Nz(vWhere, "") = "" Then
      MsgBox "There are no search criteria selected." &amp; vbCrLf &amp; vbCrLf &amp; _
             "Search Cancelled.", vbInformation, "Search Canceled."
   Else
      Set qd = db.CreateQueryDef("Query1", "SELECT * FROM tblRefundData? &amp; _
               " WHERE " &amp; Mid(vWhere, 6))
      db.Close
      Set db = Nothing

      DoCmd.OpenQuery "Query1", acViewNormal, acReadOnly
   End If
End Sub

L'exemple suivant montre comment utiliser l'événement BeforeUpdate d'un formulaire pour demander à ce qu'une valeur soit entrée dans un des contrôles lorsqu'un autre contrôle inclut également des données.The following example shows how to use the BeforeUpdate event of a form to require that a value be entered into one control when another control also has data.

Exemple de code fourni par :Référence du programmeur Microsoft Access 2010Sample code provided by: The Microsoft Access 2010 Programmer's Reference

Private Sub Form_BeforeUpdate(Cancel As Integer)
If (IsNull(Me.FieldOne)) Or (Me.FieldOne.Value =  "") Then
    ' No action required
Else
    If (IsNull(Me.FieldTwo)) or (Me.FieldTwo.Value = "") Then
        MsgBox "You must provide data for field 'FieldTwo', " &amp; _
            "if a value is entered in FieldOne", _
            vbOKOnly, "Required Field"
        Me.FieldTwo.SetFocus
        Cancel = True
        Exit Sub
    End If
End If

End Sub

L’exemple suivant montre comment utiliser la propriété OpenArgs pour empêcher l’ouverture d’un formulaire à partir du volet de navigation.The following example shows how to use the OpenArgs property to prevent a form from being opened from the Navigation Pane.

Private Sub Form_Open(Cancel As Integer)

If Me.OpenArgs() <> "Valid User" Then
    MsgBox "You are not authorized to use this form!", _
        vbExclamation + vbOKOnly, "Invalid Access"
    Cancel = True
End If
End Sub

L'exemple suivant montre comment utiliser l'argument WhereCondition de la méthode OpenForm pour filtrer les enregistrements affichés sur un formulaire lors de son ouverture.The following example shows how to use the WhereCondition argument of the OpenForm method to filter the records displayed on a form as it is opened.

Private Sub cmdShowOrders_Click()
If Not Me.NewRecord Then
    DoCmd.OpenForm "frmOrder", _
        WhereCondition:="CustomerID=" &amp; Me.txtCustomerID
End If
End Sub

ÉvénementsEvents

NomName
ActivateActivate
AfterDelConfirmAfterDelConfirm
AfterFinalRenderAfterFinalRender
AfterInsertAfterInsert
AfterLayoutAfterLayout
AfterRenderAfterRender
AfterUpdateAfterUpdate
ApplyFilterApplyFilter
BeforeDelConfirmBeforeDelConfirm
BeforeInsertBeforeInsert
BeforeQueryBeforeQuery
BeforeRenderBeforeRender
BeforeScreenTipBeforeScreenTip
BeforeUpdateBeforeUpdate
ClickClick
CloseClose
CommandBeforeExecuteCommandBeforeExecute
CommandCheckedCommandChecked
CommandEnabledCommandEnabled
CommandExecuteCommandExecute
CurrentCurrent
DataChangeDataChange
DataSetChangeDataSetChange
DblClickDblClick
DeactivateDeactivate
DeleteDelete
DirtyDirty
ErrorError
FilterFilter
GotFocusGotFocus
KeyDownKeyDown
KeyPressKeyPress
KeyUpKeyUp
LoadLoad
LostFocusLostFocus
MouseDownMouseDown
MouseMoveMouseMove
MouseUpMouseUp
MouseWheelMouseWheel
OnConnectOnConnect
OnDisconnectOnDisconnect
OpenOpen
PivotTableChangePivotTableChange
QueryQuery
ResizeResize
SelectionChangeSelectionChange
TimerTimer
UndoUndo
UnloadUnload
ViewChangeViewChange

MéthodesMethods

NomName
GoToPageGoToPage
MoveMove
RecalcRecalc
RefreshRefresh
RepaintRepaint
RequeryRequery
SetFocusSetFocus
UndoUndo

PropriétésProperties

NomName
ActiveControlActiveControl
AfterDelConfirmAfterDelConfirm
AfterFinalRenderAfterFinalRender
AfterInsertAfterInsert
AfterLayoutAfterLayout
AfterRenderAfterRender
AfterUpdateAfterUpdate
AllowAdditionsAllowAdditions
AllowDatasheetViewAllowDatasheetView
AllowDeletionsAllowDeletions
AllowEditsAllowEdits
AllowFiltersAllowFilters
AllowFormViewAllowFormView
AllowLayoutViewAllowLayoutView
AllowPivotChartViewAllowPivotChartView
AllowPivotTableViewAllowPivotTableView
ApplicationApplication
AutoCenterAutoCenter
AutoResizeAutoResize
BeforeDelConfirmBeforeDelConfirm
BeforeInsertBeforeInsert
BeforeQueryBeforeQuery
BeforeRenderBeforeRender
BeforeScreenTipBeforeScreenTip
BeforeUpdateBeforeUpdate
BookmarkBookmark
BorderStyleBorderStyle
CaptionCaption
ChartSpaceChartSpace
CloseButtonCloseButton
CommandBeforeExecuteCommandBeforeExecute
CommandCheckedCommandChecked
CommandEnabledCommandEnabled
CommandExecuteCommandExecute
ControlBoxControlBox
ControlsControls
CountCount
CurrentRecordCurrentRecord
CurrentSectionLeftCurrentSectionLeft
CurrentSectionTopCurrentSectionTop
CurrentViewCurrentView
CycleCycle
DataChangeDataChange
DataEntryDataEntry
DataSetChangeDataSetChange
DatasheetAlternateBackColorDatasheetAlternateBackColor
DatasheetBackColorDatasheetBackColor
DatasheetBorderLineStyleDatasheetBorderLineStyle
DatasheetCellsEffectDatasheetCellsEffect
DatasheetColumnHeaderUnderlineStyleDatasheetColumnHeaderUnderlineStyle
DatasheetFontHeightDatasheetFontHeight
DatasheetFontItalicDatasheetFontItalic
DatasheetFontNameDatasheetFontName
DatasheetFontUnderlineDatasheetFontUnderline
DatasheetFontWeightDatasheetFontWeight
DatasheetForeColorDatasheetForeColor
DatasheetGridlinesBehaviorDatasheetGridlinesBehavior
DatasheetGridlinesColorDatasheetGridlinesColor
DefaultControlDefaultControl
DefaultViewDefaultView
DirtyDirty
DisplayOnSharePointSiteDisplayOnSharePointSite
DividingLinesDividingLines
FastLaserPrintingFastLaserPrinting
FetchDefaultsFetchDefaults
FilterFilter
FilterOnfilterOn
FilterOnLoadFilterOnLoad
FitToScreenFitToScreen
FormForm
FrozenColumnsFrozenColumns
GridXGridX
GridYGridY
HasModuleHasModule
HelpContextIdHelpContextID
HelpFileHelpFile
HorizontalDatasheetGridlineStyleHorizontalDatasheetGridlineStyle
HwndHwnd
InputParametersInputParameters
InsideHeightInsideHeight
InsideWidthInsideWidth
KeyPreviewKeyPreview
LayoutForPrintLayoutForPrint
MaxRecButtonMaxRecButton
MaxRecordsMaxRecords
MenuBarMenuBar
MinMaxButtonsMinMaxButtons
ModalModal
ModuleModule
MouseWheelMouseWheel
MoveableMoveable
NameName
NavigationButtonsNavigationButtons
NavigationCaptionNavigationCaption
NewRecordNewRecord
OnActivateOnActivate
OnApplyFilterOnApplyFilter
OnClickOnClick
OnCloseOnClose
OnConnectOnConnect
OnCurrentOnCurrent
OnDblClickOnDblClick
OnDeactivateOnDeactivate
OnDeleteOnDelete
OnDirtyOnDirty
OnDisconnectOnDisconnect
OnErroronError
OnFilterOnFilter
OnGotFocusOnGotFocus
OnInsertOnInsert
OnKeyDownOnKeyDown
OnKeyPressOnKeyPress
OnKeyUpOnKeyUp
OnLoadOnLoad
OnLostFocusOnLostFocus
OnMouseDownOnMouseDown
OnMouseMoveOnMouseMove
OnMouseUpOnMouseUp
OnOpenOnOpen
OnResizeOnResize
OnTimerOnTimer
OnUndoOnUndo
OnUnloadOnUnload
OpenArgsOpenArgs
OrderBy$orderby
OrderByOnOrderByOn
OrderByOnLoadOrderByOnLoad
OrientationOrientation
PagePage
PagesPages
PaintingPainting
PaintPalettePaintPalette
PaletteSourcePaletteSource
ParentParent
PicturePicture
PictureAlignmentPictureAlignment
PictureDataPictureData
PicturePalettePicturePalette
PictureSizeModePictureSizeMode
PictureTilingPictureTiling
PictureTypePictureType
PivotTablepivotTable
PivotTableChangePivotTableChange
PopUpPopUp
PrinterPrinter
PropertiesProperties
PrtDevModePrtDevMode
PrtDevNamesPrtDevNames
PrtMipPrtMip
QueryQuery
RecordLocksRecordLocks
RecordSelectorsRecordSelectors
RecordsetRecordset
RecordsetCloneRecordsetClone
RecordsetTypeRecordsetType
RecordSourceRecordSource
RecordSourceQualifierRecordSourceQualifier
ResyncCommandResyncCommand
RibbonNameRibbonName
RowHeightrowHeight
ScrollBarsScrollBars
SectionSection
SelectionChangeSelectionChange
SelHeightSelHeight
SelLeftSelLeft
SelTopSelTop
SelWidthSelWidth
ServerFilterServerFilter
ServerFilterByFormServerFilterByForm
ShortcutMenuShortcutMenu
ShortcutMenuBarShortcutMenuBar
SplitFormDatasheetSplitFormDatasheet
SplitFormOrientationSplitFormOrientation
SplitFormPrintingSplitFormPrinting
SplitFormSizeSplitFormSize
SplitFormSplitterBarSplitFormSplitterBar
SplitFormSplitterBarSaveSplitFormSplitterBarSave
SubdatasheetExpandedSubdatasheetExpanded
SubdatasheetHeightSubdatasheetHeight
TagTag
TimerIntervalTimerInterval
ToolbarToolbar
UniqueTableUniqueTable
UseDefaultPrinterUseDefaultPrinter
VerticalDatasheetGridlineStyleVerticalDatasheetGridlineStyle
ViewChangeViewChange
ViewsAllowedViewsAllowed
VisibleVisible
WidthWidth
WindowHeightWindowHeight
WindowLeftWindowLeft
WindowTopWindowTop
WindowWidthWindowWidth

À propos des collaborateursAbout the Contributors

Luke Chung est le fondateur et le président de FMS, Inc., l’un des principaux fournisseurs de solutions de base de données et d’outils de développement personnalisés.Luke Chung is the founder and president of FMS, Inc., a leading provider of custom database solutions and developer tools.

UtterAccess est le premier forum d’aide et wiki de Microsoft Access.UtterAccess is the premier Microsoft Access wiki and help forum. Click here to join.

Wrox Press est guidé par la philosophie de programmeur à programmeur. Les livres Wrox sont écrits par des programmeurs pour des programmeurs et la marque Wrox est synonyme de solutions de référence aux problèmes de programmation concrets.Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

Voir aussiSee also

Référence du modèle objet AccessAccess Object Model Reference

© 2018 Microsoft