ComboBox object (Admission)

This object corresponds to a combo box control. The combo box control combines the features of a text box and a list box. Apply a combo box when you want the option of either typing a value or selecting a value from a predefined listing.

Remarks

Control Tool
Combo box control Combo box tool

In Grade view, Microsoft Access doesn't display the list until yous click the philharmonic box's arrow.

If you take Control Wizards on before you select the combo box tool, you tin create a combo box with a wizard. To plough Control Wizards on or off, click the Command Wizards tool in the toolbox.

The setting of the LimitToList property determines whether you can enter values that aren't in the list.

The list tin be unmarried- or multiple-column, and the columns can appear with or without headings.

Example

The following example shows how to use multiple ComboBox controls to supply criteria for a query.

              Individual Sub cmdSearch_Click()     Dim db As Database     Dim qd As QueryDef     Dim vWhere Every bit Variant          Set db = CurrentDb()          On Error Resume Side by side     db.QueryDefs.Delete "Query1"     On Error GoTo 0          vWhere = Null     vWhere = vWhere & " AND [PymtTypeID]=" & Me.cboPaymentTypes     vWhere = vWhere & " AND [RefundTypeID]=" & Me.cboRefundType     vWhere = vWhere & " AND [RefundCDMID]=" & Me.cboRefundCDM     vWhere = vWhere & " AND [RefundOptionID]=" & Me.cboRefundOption     vWhere = vWhere & " AND [RefundCodeID]=" & Me.cboRefundCode          If Nz(vWhere, "") = "" Then         MsgBox "There are no search criteria selected." & vbCrLf & vbCrLf & _         "Search Cancelled.", vbInformation, "Search Canceled."              Else         Set qd = db.CreateQueryDef("Query1", "SELECT * FROM tblRefundData WHERE " & _         Mid(vWhere, vi))                  db.Close         Set db = Nada                  DoCmd.OpenQuery "Query1", acViewNormal, acReadOnly     Cease If Finish Sub                          

The post-obit example shows how to set the RowSource property of a combo box when a class is loaded. When the form is displayed, the items stored in the Departments field of the tblDepartment combo box are displayed in the cboDept combo box.

              Private Sub Form_Load()     Me.Caption = "Today is " & Format$(Date, "dddd mmm-d-yyyy")     Me.RecordSource = "tblDepartments"     DoCmd.Maximize       txtDept.ControlSource = "Department"     cmdClose.Caption = "&Close"     cboDept.RowSourceType = "Table/Query"     cboDept.RowSource = "SELECT Department FROM tblDepartments" End Sub                          

The post-obit example shows how to create a combo box that is bound to 1 cavalcade while displaying another. Setting the ColumnCount property to 2 specifies that the cboDept combo box will display the outset two columns of the data source specified past the RowSource property. Setting the BoundColumn property to 1 specifies that the value stored in the first column will be returned when you inspect the value of the combo box.

The ColumnWidths belongings specifies the width of the two columns. By setting the width of the first column to 0in., the first column is not displayed in the combo box.

              Individual Sub cboDept_Enter()     With cboDept         .RowSource = "SELECT * FROM tblDepartments Society By Department"         .ColumnCount = 2         .BoundColumn = 1         .ColumnWidths = "0in.;1in."     Terminate With Terminate Sub                          

The following example shows how to add together an detail to a bound combo box.

              Individual Sub cboMainCategory_NotInList(NewData As Cord, Response As Integer)      On Error GoTo Error_Handler     Dim intAnswer As Integer     intAnswer = MsgBox("""" & NewData & """ is not an approved category. " & vbcrlf _         & "Do you want to add information technology now?", vbYesNo + vbQuestion, "Invalid Category")      Select Example intAnswer         Case vbYes             DoCmd.SetWarnings False             DoCmd.RunSQL "INSERT INTO tlkpCategoryNotInList (Category) " & _                           "Select """ & NewData & """;"             DoCmd.SetWarnings Truthful             Response = acDataErrAdded         Instance vbNo             MsgBox "Delight select an item from the list.", _                 vbExclamation + vbOKOnly, "Invalid Entry"             Response = acDataErrContinue      Terminate Select      Exit_Procedure:         DoCmd.SetWarnings True         Exit Sub      Error_Handler:         MsgBox Err.Number & ", " & Err.Description         Resume Exit_Procedure         Resume  End Sub                          

Events

  • AfterUpdate
  • BeforeUpdate
  • Change
  • Click
  • DblClick
  • Dirty
  • Enter
  • Exit
  • GotFocus
  • KeyDown
  • KeyPress
  • KeyUp
  • LostFocus
  • MouseDown
  • MouseMove
  • MouseUp
  • NotInList
  • Disengage

Methods

  • AddItem
  • Dropdown
  • Motion
  • RemoveItem
  • Requery
  • SetFocus
  • SizeToFit
  • Undo

Properties

  • AddColon
  • AfterUpdate
  • AllowAutoCorrect
  • AllowValueListEdits
  • Application
  • AutoExpand
  • AutoLabel
  • BackColor
  • BackShade
  • BackStyle
  • BackThemeColorIndex
  • BackTint
  • BeforeUpdate
  • BorderColor
  • BorderShade
  • BorderStyle
  • BorderThemeColorIndex
  • BorderTint
  • BorderWidth
  • BottomMargin
  • BottomPadding
  • BoundColumn
  • CanGrow
  • CanShrink
  • Column
  • ColumnCount
  • ColumnHeads
  • ColumnHidden
  • ColumnOrder
  • ColumnWidth
  • ColumnWidths
  • Controls
  • ControlSource
  • ControlTipText
  • ControlType
  • DecimalPlaces
  • DefaultValue
  • DisplayAsHyperlink
  • DisplayWhen
  • Enabled
  • EventProcPrefix
  • FontBold
  • FontItalic
  • FontName
  • FontSize
  • FontUnderline
  • FontWeight
  • ForeColor
  • ForeShade
  • ForeThemeColorIndex
  • ForeTint
  • Format
  • FormatConditions
  • GridlineColor
  • GridlineShade
  • GridlineStyleBottom
  • GridlineStyleLeft
  • GridlineStyleRight
  • GridlineStyleTop
  • GridlineThemeColorIndex
  • GridlineTint
  • GridlineWidthBottom
  • GridlineWidthLeft
  • GridlineWidthRight
  • GridlineWidthTop
  • Height
  • HelpContextId
  • HideDuplicates
  • HorizontalAnchor
  • Hyperlink
  • IMEHold
  • IMEMode
  • IMESentenceMode
  • InheritValueList
  • InputMask
  • InSelection
  • IsHyperlink
  • IsVisible
  • ItemData
  • ItemsSelected
  • KeyboardLanguage
  • LabelAlign
  • LabelX
  • LabelY
  • Layout
  • LayoutID
  • Left
  • LeftMargin
  • LeftPadding
  • LimitToList
  • ListCount
  • ListIndex
  • ListItemsEditForm
  • ListRows
  • ListWidth
  • Locked
  • Proper name
  • NumeralShapes
  • OldBorderStyle
  • OldValue
  • OnChange
  • OnClick
  • OnDblClick
  • OnDirty
  • OnEnter
  • OnExit
  • OnGotFocus
  • OnKeyDown
  • OnKeyPress
  • OnKeyUp
  • OnLostFocus
  • OnMouseDown
  • OnMouseMove
  • OnMouseUp
  • OnNotInList
  • OnUndo
  • Parent
  • Properties
  • ReadingOrder
  • Recordset
  • RightMargin
  • RightPadding
  • RowSource
  • RowSourceType
  • ScrollBarAlign
  • Section
  • Selected
  • SelLength
  • SelStart
  • SelText
  • SeparatorCharacters
  • ShortcutMenuBar
  • ShowOnlyRowSourceValues
  • SmartTags
  • SpecialEffect
  • StatusBarText
  • TabIndex
  • TabStop
  • Tag
  • Text
  • TextAlign
  • ThemeFontIndex
  • Top
  • TopMargin
  • TopPadding
  • ValidationRule
  • ValidationText
  • Value
  • VerticalAnchor
  • Visible
  • Width

See also

  • Admission Object Model Reference

Back up and feedback

Have questions or feedback virtually Office VBA or this documentation? Please see Function VBA support and feedback for guidance nigh the ways yous can receive support and provide feedback.