ACC: How to Add New Record to a Combo Box with a Double-ClickID: Q88148
|
Moderate: Requires basic macro, coding, and interoperability skills.
This article describes how to set up a macro so that you can add new values
to a combo box. The article uses the Orders form in the sample database
Northwind.mdb (or Nwind.mdb in earlier versions) as an example.
Follow these steps to modify the Orders form so that you can add new values
to the Salesperson combo box:
In Microsoft Access 97
----------------------
Macro Name Condition Action
-----------------------------------------------------
NewRecord OpenForm
OnClose [EmployeeID] Is Not Null RunCommand
... SelectObject
... ReQuery
... SetValue
NewRecord Actions
---------------------------------------------------------
OpenForm
Form Name: Employees
View: Form
Data Mode: Add
Window Mode: Normal
OnClose Actions
-------------------------------------------------------------------
RunCommand
Command: SaveRecord
SelectObject
Object Type: Form
Object Name: Orders
In Database Window: No
ReQuery
ControlName: EmployeeId
SetValue
Item: Forms!Orders![EmployeeID]
Expression: Forms!Employees![EmployeeID]
In Microsoft Access 7.0
-----------------------
Macro Name Condition Action
-----------------------------------------------------
NewRecord OpenForm
OnClose [EmployeeID] Is Not Null DoMenuItem
... SelectObject
... ReQuery
... SetValue
NewRecord Actions
---------------------------------------------------------
OpenForm
Form Name: Employees
View: Form
Data Mode: Add
Window Mode: Normal
OnClose Actions
-------------------------------------------------------------------
DoMenuItem
Menu Bar: Form
Menu Name: Records
Command: Save Record
SelectObject
Object Type: Form
Object Name: Orders
In Database Window: No
ReQuery
ControlName: EmployeeId
SetValue
Item: Forms!Orders![EmployeeID]
Expression: Forms!Employees![EmployeeID]
In Microsoft Access 1.x and 2.0
-------------------------------
Macro Name Condition Action
-----------------------------------------------------
NewRecord OpenForm
OnClose [Employee ID] Is Not Null DoMenuItem
... SelectObject
... ReQuery
... SetValue
NewRecord Actions
---------------------------------------------------------
OpenForm
Form Name: Employees
View: Form
Data Mode: Add
Window Mode: Normal
OnClose Actions
-------------------------------------------------------------------
DoMenuItem
Menu Bar: Form
Menu Name: File
Command: Save Record
SelectObject
Object Type: Form
Object Name: Orders
In Database Window: No
ReQuery
ControlName: Employee Id
SetValue
Item: Forms!Orders![Employee ID]
Expression: Forms!Employees![Employee ID]
Additional query words: doubleclick update record
Keywords : FmsEvnt
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: May 25, 1999