Access Question on Drop Down List in Access 2007

Hello Everyone,

I have a Drop Down List in my Access 2007 application that has a drop down List for Vehicle Type with this listing:

Vehicle Types
•      Motorcycle
•      Three-Wheeler
•      Car
•      Van
•      Pickup
•      SUV
•      Motor Home
•      Boat
•      Personal Water Craft
•      Truck
•      Trailer
•      Truck & Trailer
•      Self-propelled Campers
•      Other-specify


If the Boat is selected in the Drop Down, I want another Drop Down List to show for Boat with these fields:

Fields for Boats
•      Boat Year
•      Boat Make
•      Boat Hull Serial
•      Boat Reg Number
•      Boat Decal
•      Boat Length


My question, is there a way in Access 2007 to hide the Boat Field Drop Down until actually needed.  The Boat Field listing would only show if the Boat is selected as a drop down choice somehow.

In VB I can do this with logic by using an IF Statement or Case Statement.  

If  the Boat Field is selected in the Vehicle Type  Dropdown, make the Boat Field Visible, otherwise keep invisiblew inless needed.


jjc9809
jjc9809Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
bigjdveConnect With a Mentor Commented:
I would use the visible attribute on the 2nd Drop Down List (Combo-Box). You can then build the if statement in the VB for the event.

Something to the effect of

If record.field = boat

then

combobox2.visible = yes (true)

Let me know if  this helps. I have done this in the past and it worked.Remember in Access you can always use VB for anything.
0
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
you can still use the select or If then statement in the afterupdate event of the first combo

private sub cboVehicleType_afterupdate()

if me.cboVehicleType="Boats" then
   me.cboBoat.visible=true
   me.cboBoat.RowSource= < select statement here >

end if


end sub
0
 
MINDSUPERBConnect With a Mentor Commented:
You need to set the Visible property of your cboBoat into No. Then, you may try this code:

Private Sub cboBoat_AfterUpdate()
If Me.cboVehicles = "Boat" Then
Me.cboBoat.Visible = True
Else
Me.cboBoat.Visible = False
End If
End Sub


Sincerely,
Ed
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
you can still use the select or If then statement in the afterupdate event of the first combo

private sub cboVehicleType_afterupdate()

if me.cboVehicleType="Boats" then
   me.cboBoat.visible=true
   me.cboBoat.RowSource= < select statement here >

  else

  me.cboBoat.visible=false
end if


end sub
0
 
MINDSUPERBCommented:
Sorry Cap.

Ed
0
 
jjc9809Author Commented:
Hi Everyone,

I can't get this to work.  My Table is called Vehicles_tbl.  I have the VehicleType_vch in the table as well as BoatYear which is a comboBox field.  I am trying just top get
one of the field visible and not visible based on the If StateMent Logic.

My Field on the Vehicle Data Entry Form is VehicleType_Vch.  I have right clicked the VehicleType_vch field and on the After Update event I have placed the code:

If VehicleType_Vch = "Boat" Then
BoatYear.Visible = True
Else
Boat Year.Visible = False

This is just simple logic.  What I am doing wrong here?

The computer should know what BoatYear is since I have placed the correct name of it in the Vehicles Table that the form was created from.



Are you sure the After Update event is used and not the Before Update event or On Focus Update Event?

0
 
Rey Obrero (Capricorn1)Commented:
you have to use the afterupdate event of the combo for vehicle type..

what is the name of the combo for vehicleType_vch?

what is the name of the combo for BoatYear ?


can you upload a copy of the db..
0
 
jjc9809Author Commented:
The name of the Combo for VehicleType_vch is "VehicleType_vch"
The Name of the Combo for BoatYear is "BoatYear"

jjc9809
0
 
jjc9809Author Commented:
Hi Everyone,

I got it to work.  I was using an incorrect name for the Combo Box.

jjc9809
0
 
Rey Obrero (Capricorn1)Commented:
good..
0
 
jjc9809Author Commented:
Thanks Everyone!

jjc9809
0
All Courses

From novice to tech pro — start learning today.