Solved

Access Question on Drop Down List in Access 2007

Posted on 2011-09-21
11
319 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:jjc9809
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 3

Accepted Solution

by:
bigjdve earned 125 total points
ID: 36574775
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
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 250 total points
ID: 36574789
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
 
LVL 19

Assisted Solution

by:MINDSUPERB
MINDSUPERB earned 125 total points
ID: 36574798
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
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 250 total points
ID: 36574802
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
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 36574803
Sorry Cap.

Ed
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:jjc9809
ID: 36576175
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
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 36576214
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
 

Author Comment

by:jjc9809
ID: 36576389
The name of the Combo for VehicleType_vch is "VehicleType_vch"
The Name of the Combo for BoatYear is "BoatYear"

jjc9809
0
 

Author Comment

by:jjc9809
ID: 36576565
Hi Everyone,

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

jjc9809
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 36576582
good..
0
 

Author Closing Comment

by:jjc9809
ID: 36576583
Thanks Everyone!

jjc9809
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now