473,385 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

if statement problem

35
hi,

i want a text box to show "change" if the value of total is less than zero and "balance" if the value is greater than zero. i tried this code on the afterupdate event but it won't work. please help...

Expand|Select|Wrap|Line Numbers
  1. If Me.txttotal < 0 Then
  2. Me.txtchange = "change"
  3. ElseIf Me.txttotal > 0 Then
  4. Me.txtchange = "balance"
  5. Else
  6.     ' do nothing
  7.  
  8. End If
Apr 30 '11 #1
2 1476
beacon
579 512MB
Hi Mac,

I would use the BeforeUpdate event, not the AfterUpdate event. You're essentially validating the data in txtTotal, then updating the value in txtChange. Typically, all data validations are done using the BeforeUpdate event.

Of course, this assumes that the format for your txtTotal textbox is setup to allow for negative values.

Also, in case you want to reduce the number of lines of code, you really don't need the 'Else' part of your 'If' statement if you aren't going to test a condition.
Apr 30 '11 #2
NeoPa
32,556 Expert Mod 16PB
Mac Rod:
but it won't work.
We'd have to know what you mean by not working Mac. You may have any weird expectation of this, but without saying what that is it's hard to comment.

Also, to check your code properly (an initial check confirms it's not tidy but it should nevertheless produce sensible results assuming all else matches - like object names etc), we'd need to see it in the context of its procedure at least.
May 1 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Graham James Campbell CS2000 | last post by:
Having a nightmare problem with this and would appreciate any and all help. The situation is I want to move from a webform and format the user inputted text into some html I am storing in a...
0
by: Gary Bouchard | last post by:
MYSQL Version 4.0.15 Can some anyone tell me what is wrong with the following statement; select bookings.key1,bookings.surname,bookings.firstname,bookings.bookingseqno,bookings.filetype from...
13
by: kieran | last post by:
Hi, I have the following SQL statement which is pulling a few details from a database. As you can see, there is only the one table from which i am creating a temporary copy. The reason I do...
6
by: DLP22192 | last post by:
I have the following single-line if statement that is evaluating true even though it shouldn't. I have never seen this before and I am concerned that this can happen in other areas of my code. ...
1
by: Ian Davies | last post by:
I am using a simple delete statement in my php script (below) $q = "DELETE FROM commenttype WHERE TypeID=".$_POST; the problem is it doesnt delete the whole row it only deletes the text in one...
4
by: bokke | last post by:
Hi, I have a page that has several stories that run on it from a mysql database. Right now I use this code: <img src="Images/NewsPics/<?php echo $row;?>.jpg" border="1"to display the image. ...
5
by: JamesHoward | last post by:
I have a problem with python's asyncore module throwing a bad file descriptor error. The code might be difficult to copy here, but the problem is essentially: The server wants to sever the...
2
by: gool | last post by:
Hi, I am writing this piece of code: $sqlquery="WITH journey (TO_TOWN, STEPS, DISTANCE, WAY) AS (SELECT DISTINCT JNY_FROM_TOWN, 0, 0, CAST('PARIS' AS VARCHAR(MAX)) FROM T_JOURNEY ...
6
by: jephperro | last post by:
Hi there, I'm having a really tough time with a SQL statement and I am wondering if someone is able to help out or point me in the right direction. I have a table of names which can be very...
1
by: Maklar60 | last post by:
I am attempting to execute an INSERT statement on my page but continually get the following error: Microsoft OLE DB Provider for ODBC Drivers error '80040e14' Incorrect syntax near '<'. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.