Solved

Putting a calculated field on a form (easy)!

Posted on 2011-03-17
3
262 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 400 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 100 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

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…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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…

726 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