Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2005

Tip: Looking for answers? Try searching our database.

Carrying a value over and adding .1

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anthony Viscomi - 04 Feb 2005 13:58 GMT
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
Tim Ferguson - 04 Feb 2005 17:45 GMT
> 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
Marshall Barton - 04 Feb 2005 18:00 GMT
>I have the following:
>
[quoted text clipped - 5 lines]
>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

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.