?
Solved

Using COleCurrency with ODBC and Visual C++

Posted on 2004-03-26
4
Medium Priority
?
413 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

770 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