Solved

Using COleCurrency with ODBC and Visual C++

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add content to output file 4 62
ORA-01403: no data found 43 90
VBA "SendKeys" Syntax for Multiple Keystrokes 7 103
Window placement 17 75
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…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

920 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

16 Experts available now in Live!

Get 1:1 Help Now