Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open form Question

Status
Not open for further replies.

loneranger27

Programmer
Apr 22, 2003
94
0
0
US
Hi,

I have a form where we enter information about a car.
and the user selects the type of car from a combo box.

What I want to do is that if the combo says dodge truck then the truck form opens if it says dodge car then the car form opens and so on.
I tried if then statements and did not have goodluck
if [combo22] = "dodge truck" then docmd.Openform ("truck")
the form opens and I get an error that access cannot find the field forms referred to in the expression. The truck form is a linked form.

Any help would be appreciated.
Thanks
 
lone,

A nice way to do this is to have a combo box (srchCombo)
that displays keys from some table. In the AfterUpdate
event of the combo, do:

DoCmd.OpenForm "VehicleForm",,,"[EditVehicles]"

This will open the form and display all vehicles of a
certain type.

In you situation, use the AfterUpdate event:

Code:
If InStr(1, Me.srchCombo, "truck") > 0 Then
   DoCmd.OpenForm "truck"
ElseIf InStr(1, Me.srchCombo, "van") > 0 Then
   DoCmd.OpenForm "van"
End If

You really shouldn't need to have a different form for
each type of vehicle. It will mean more work for you
in the long run.

Wayne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top