From my previous post:
"You'd have to rename your forms, placing a prefix before each name, i.e.
edForm1 for a form you want to open in
Edit mode and
adForm2 for a form you want to open in
Add mode. One combobox would retrieve all forms with the ed prefix and the other would retrieve all forms with the ad prefix.
While this doesn’t involve a lot of code, it does involve a bit of setting up of of properties that can be daunting for a newbie, and so I’m going to give you step-by-step instructions on this.
Place two comboboxes on your form. When the Wizard comes up click on “Cancel”
For each combobox
Right click on the combobox
Click on
Properties
Click on
Other Enter Names for Combobox (
SelectFormsEdit and
SelectFormsAdd respectively)
Click on
Data
Set
Row Source Type to
Tables/Query
Set the
Row Source by copying and pasting the SQL statements below
Row Source for Forms in Edit Mode
SELECT [MSysObjects].[Name] FROM MsysObjects WHERE (Left$([Name],2) = "ed") And ([MSysObjects].[Type])=-32768 ORDER BY [MSysObjects].[Name];
Row Source for Forms in Add Mode
SELECT [MSysObjects].[Name] FROM MsysObjects WHERE (Left$([Name],2) = "ad") And ([MSysObjects].[Type])=-32768 ORDER BY [MSysObjects].[Name];
************************************************** *****
Right click on the combobox
Click on
Properties
Click on
Events
Click to the right of the
AfterUpdateProperty box
Click on
Code Builder
For the appropriate Comboboxes enter the code below
DoCmd.OpenForm SelectFormsAdd, , , , acFormAdd
DoCmd.OpenForm SelectFormsEdit, , , , acFormEdit
so that the code looks like this
- Private Sub SelectFormsAdd_AfterUpdate()
-
DoCmd.OpenForm SelectFormsAdd, , , , acFormAdd
-
End Sub
-
- Private Sub SelectFormsEdit_AfterUpdate()
-
DoCmd.OpenForm SelectFormsEdit, , , , acFormEdit
-
End Sub
Good Luck!
Linq
;0)>