Open Forms??? (1 Viewer)

DRananahan

Registered User.
Local time
Today, 15:20
Joined
Jul 24, 2000
Messages
14
I have a question regarding using VBA to open a form.....

I have an unbound form that contains a combo box with several different types of collateral (i.e. Real Estate, Titled Vehicles, UCC collateral, Life Insurance, Stock/Negotiables, etc.) The lookup table has 3 columns (PrimaryKey, CollType, FormAssociation) For each type of collateral, there is different information to be entered to complete the transaction. I have set up tables for each type along with a form for each table.

Is there a way rather than assigning a number value to each collateral type then writing code using the if statement to open the form i.e.:

If CollType = 1 then
DoCmd.OpenForm "frmREColl"
ElseIf CollType = 2 then
DoCmd.OpenForm "frmTitledVeh"
ElseIf ......

I would rather have

DoCmd.OpenForm "form association name"

I would appreciate any help with this.

Thank you,
doug
 

charityg

Registered User.
Local time
Today, 15:20
Joined
Apr 17, 2001
Messages
634
All you need to do is add the FormAssociation field to the underlying query of the combobox and then refer to it as the DocName.

Go to the rowsource query of the combobox.
You probably have the first two fields already in the grid. Add the FormAssociation field.

On the format tab of the combobox's property's window. Set column count to 3 and columnwidth to whatever is already there + ;0 so it will look something like 0";2.0";0"

Then to open form
Dim strDocName as string
strDocName=CollType.column(2)

'This refers to the 3rd column of the combobox

DoCmd.OpenForm strDocName


Let me know if you have any problems!

Charity

[This message has been edited by charityg (edited 06-15-2001).]

[This message has been edited by charityg (edited 06-15-2001).]
 

Users who are viewing this thread

Top Bottom