Solved

Putting a calculated field on a form (easy)!

Posted on 2011-03-17
3
257 Views
Last Modified: 2012-05-11
Hi see attached.

I have a very simple form based on a very simple table.
If the [Price] field is > 100 then I want to display the wording "High"

See code below where PriceType is determined to be "high" or "low" .

How do I get the "PriceType" displayed on the actual form.  See my attempt gives an error.
Private Sub Form_Current()
Dim PriceType As String
If Me.price > 100 Then PriceType = "High" Else PriceType = "Low"
End Sub

Open in new window

Database8.zip
0
Comment
Question by:Patrick O'Dea
3 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 400 total points
Comment Utility
Add a textbox to the form.
If the name of the textbox is txtPriceType then you add another line

If Me.price > 100 Then PriceType = "High" Else PriceType = "Low"
me.txtPricetype = pricetype

You could do without the variable completely and just set the textbox directly in the 'if' statement.
0
 
LVL 10

Assisted Solution

by:t_hungate
t_hungate earned 100 total points
Comment Utility
You can also do this by adding two hidden textboxes one for high and one for low, then use your if statement to change the visible property of the textbox.

If Me.txtPrice > 100 then
    Me.txtPriceTypeHigh.visible = true
    Me.txtPriceTypeLow.visible = false
else
    Me.txtPriceTypeHigh.visible = false
    Me.txtPriceTypeLow.visible = true
End if
0
 

Author Closing Comment

by:Patrick O'Dea
Comment Utility
thanks again
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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…

763 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

8 Experts available now in Live!

Get 1:1 Help Now