Solved

Using COleCurrency with ODBC and Visual C++

Posted on 2004-03-26
4
408 Views
Last Modified: 2013-11-20
Hi,

I am writing a database application (using access).  I have data fields in the database that are defined as currency.  I have defined edit boxes within my applications as COleCurrency.  I am having problems using
rfx...

From research on the web it seems that the correct call is rfx_byte()...  (it's not rfx_currecny as that is only for DAO, as far as I can tell)

however, I get the following error when I use that:

rror C2664: 'RFX_Byte' : cannot convert parameter 3 from 'class COleCurrency' to 'unsigned char &'
        A reference that is not to 'const' cannot be bound to a non-lvalue

line of code looks like:

      RFX_Byte(pFX, _T("[CRDAmount]"), m_CRDAmount);

where m_CRDAmount is of the COleCurrency type.

So how do I fix this?

Nasa
0
Comment
Question by:nasa
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:GJanusz
ID: 10689121
That error is pretty common, and I sure have seen it my share of times.  I don't have time to look up/test my answer right now, so I'll just quickly point out that RFX_Byte doesn't have a chance of working unless m_CRDAmount is 1 byte long (which it isn't).  The other thing is that the parameter types to the RFX_ functions are very indicative of what variable types they will work with.  (RFX_Byte takes a BYTE&.)
0
 
LVL 1

Author Comment

by:nasa
ID: 10690796
ok,

follow all that -- just wish I knew the best way to fix it....


Nasa
0
 
LVL 1

Accepted Solution

by:
GJanusz earned 125 total points
ID: 10691498
My sample code is at my previous employer, so all I can do now is point the way.  You will be well served by digging into RFX_ a bit.  If there was a neat RFX_ trick, it would only take 2 minutes to get the answer to your problem (and someone may yet have one for you!, but I don't).  However, if you have the time and inclination, you'll plan better for the future by writing your own RFX_ function and use it in your DoFieldExchange().

It appears that some of the hard work for such a custom-built RFX_ function can done by utilizing CFieldExchange::Default().  Look up what RFX_Double() does and how it uses Default().

Another place to start in MSDN is http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_record_field_exchange.3a_.how_rfx_works.asp
(i.e., all the RFX_ documentation).
0
 
LVL 1

Author Comment

by:nasa
ID: 10705507
Ok,

That's enough to scare me off....  I will just use long's (it just money) and handle the coversions/display myself.  Thanks for the info


Nasa
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question