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 / Forms Programming / January 2008

Tip: Looking for answers? Try searching our database.

passing operator as variable

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TonyT - 17 Jan 2008 20:47 GMT
Hi,

I have a form for Importing parts lists into my database, however the format
of each is different, some have just List price & some list & cost, so I have
a series of Comboboxes so the user can select column name, operator +_*/ and
a textbox for a value between 0-100 (%).

I am trying to find a way to display sample data in text boxes to show the
results of the selected calculations, but I can't figure out how to pass the
operator as a variable.

Sample code;

Me.txtExCost = (Me.lstSample.Column(lngCol)) & strOpCost & (sglPerCost *
(Me.lstSample.Column(lngCol)) / 100)

returns '2.85-0.285' not 2.565 where
(Me.lstSample.Column(lngCol)) returns 2.85
strOpCost = -
sglPerCost = 10

How do I get round this?
mscertified - 17 Jan 2008 20:55 GMT
You cannot perform arithmetic using an operator in a variable. You will have
to 'decode' the operator in code e.g.
Function OpResult(op1 as long, oper as string, op2 as long) as long
  select case oper
     case "+" OpResult = op1 + op2
     case "-" OpResult = op1 - op2
  end select
end function

-Dorian

> Hi,
>
[quoted text clipped - 18 lines]
>
> How do I get round this?
 
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.