Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing variables to tables using currency

Status
Not open for further replies.

autoIT

IS-IT--Management
May 10, 2006
68
0
0
US
OK easy problem but I dont know the cure:

how do you compare a variable to a value in a table whose colum is set to currency. The variable is dimmed as currency as well. Here's an example

if TempBid=rs.Fields.Item("Bid Amount")then
...................


in other words the value in the variable may be 28000 but the value in the table is already $28,000.00. 28000 does not equal $28,000.00, so therefore the rest of the code doesnt happen.

Adam
 



Hi,

How about a SPACE???
Code:
if TempBid=rs.Fields.Item("Bid Amount")[highlight yellow] [/highlight]then

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
... 28000 does not equal $28,000.00

If both the variable and the datafield are Currency then, indeed, 28000 does equal $28,000.00.

The formatting stuff "$", ",", "." is not stored as part of the field and is not included in the comparison of the variable with the field.

If, however, you are somehow converting one or both to some text representation before making the comparison then they are, as you say, not equal.
 
Hi,
It should be:
[blue] rs.Fields("Bid Amount").value [/blue]

Not:
[red]rs.Fields.item("Bid Amount")[/red]


Jean-Paul
Montreal
To send me E-Mail, remove “USELESSCODE”.
jp@USELESSCODEsolutionsvba.com
 
How are ya JPMontreal . . .

The [blue]Value property[/blue] is the [blue]default property[/blue] in use [purple]if no property is specified![/purple]

Making . . .
Code:
[blue]   Me!TextboxName.Value = rs.Fields("Bid Amount").value
[purple]and[/purple]
   Me!TextboxName = rs.Fields("Bid Amount")[/blue]
. . . one and the same!

Calvin.gif
See Ya! . . . . . .
 
How are ya autoIT . . .

Bear in mind that display formats are just that . . . they are simply display functions and present the data in a more recognized way . . . [blue]leaving data in the field intact[/blue].

As as example todays date [blue]12-29-2006[/blue] is actually an integer value of [blue]39080[/blue] but I don't have to tell you how many ways you can format it for view. So although you see 12-29-2006 . . . 39080 is actually whats in the field!

Same applies to all formats . . . so if myField is set for currency then
myField = 28000
is true if myfield is 28000.

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top