Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Putting a calculated field on a form (easy)!

Posted on 2011-03-17
3
Medium Priority
?
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 1600 total points
ID: 35157521
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 400 total points
ID: 35160886
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
ID: 35161185
thanks again
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

610 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