PC Review


Reply
Thread Tools Rate Thread

Carrying a value over and adding .1

 
 
Anthony Viscomi
Guest
Posts: n/a
 
      4th Feb 2005
I have the following:

Const cQuote = ""
Const cQuotePos = ""
Me.Base_Price.DefaultValue = cQuote & Me.Base_Price.Value & cQuote
Me.Position.Value = cQuotePos & Me.Position.Value & cQuote + 0.1

The 1st portion works fine; but the 2nd doesn't seem to like me adding the
..1 value to it. The control (Positon) is numeric.

Any thoughts?
Anthony


 
Reply With Quote
 
 
 
 
Tim Ferguson
Guest
Posts: n/a
 
      4th Feb 2005
"Anthony Viscomi" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> Const cQuote = ""
> Const cQuotePos = ""


Why two constants with the same value? And the same value as the inbuilt
vbNullStr?

> Me.Base_Price.DefaultValue = cQuote & Me.Base_Price.Value & cQuote


Concatenating the strings don't seem to do anything.

> Me.Position.Value = cQuotePos & Me.Position.Value & cQuote + 0.1


This will cause a datatype error: everything before the + has to be a
string value (albeit that the constants are not doing anything), and the
value afterwards is a numeric. This is legal:

me.position.value = me.position.value & "0.1"

but I don't really understand what it would be for.


Perhaps you could let us know what you are trying to achieve?

Tim F

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      4th Feb 2005
Anthony Viscomi wrote:

>I have the following:
>
>Const cQuote = ""
>Const cQuotePos = ""
>Me.Base_Price.DefaultValue = cQuote & Me.Base_Price.Value & cQuote
>Me.Position.Value = cQuotePos & Me.Position.Value & cQuote + 0.1
>
>The 1st portion works fine; but the 2nd doesn't seem to like me adding the
>.1 value to it. The control (Positon) is numeric.


Your constants are both declared as zero length strings
(ZLS) so they have no real effect in setting the
DefaultValue. Since the DefaultValue property is a string
valued property, VBA will automatically convert a numeric
value to a string and extra quotes are not needed.
Me.Base_Price.DefaultValue = Me.Base_Price.Value

However, in the position line, the simple act of using the &
operator forces VBA to convert the value to a string so the
+ also operates as a concatenation, not an addition. Just
change it to:
Me.Position.Value = Me.Position.Value + 0.1

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Carrying Value from One From/Table to another =?Utf-8?B?cmljaGFyZA==?= Microsoft Access Forms 1 25th Jun 2007 12:52 PM
Sub Total Not Carrying Over =?Utf-8?B?TURN?= Microsoft Access Form Coding 3 19th May 2006 10:39 PM
Session not carrying over jamezw Microsoft ASP .NET 1 21st Jun 2005 08:50 PM
Carrying a sum FEC Microsoft Access Reports 1 9th Nov 2003 04:59 AM
Carrying over value to a new record Amit Microsoft Access Form Coding 1 3rd Nov 2003 12:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:22 AM.