Solved

Using COleCurrency with ODBC and Visual C++

Posted on 2004-03-26
4
405 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 82
Expand macro to ask for filename column 8 35
while loop over for loop 7 79
Problem to open Excel file 15 39
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now