Solved

Access 2007 - Cost field populated based on combo box

Posted on 2015-02-15
2
223 Views
Last Modified: 2015-02-15
Access Novice....I have a simple form/database. I have a combo box [VEHICLE] with 2 possible values CAR or TRUCK and these are simply typed into the ROW SOURCE, no table lookup. I have a text field [COST], I want this field to auto populate based on the combo box choice. For example IF VEHICLE = CAR let COST = $45.00, IF VEHICLE = TRUCK let COST = $150.00. Noting complicated, I've read I can do this if I create a table with 2 columns and do a lookup, etc but I am hoping since I just have 2 possible choices I could do it a lot easier.
thx experts...Bob R
0
Comment
Question by:bobrossi56
2 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 40611061
use the afterupdate event of the combo box

private sub vehicle_afterupdate()

select case me.vehicle
    case "Car"
   me.cost="$45.00"
    case "Truck"
   me.cost="$150.00"

    case else
end select

end sub
0
 
LVL 3

Expert Comment

by:Leo Alexander
ID: 40611063
You could go to the on after update property of the combo box and do a case statement:

Select Case [combo]

Case 1

me.txtCost = "$45.00"

Case 2

me.txtCost = $150.00

End Select
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

12 Experts available now in Live!

Get 1:1 Help Now