Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2001
    Posts
    175

    Unanswered: CCur function not working on Vista machine

    I have the following code on a button on a form. When the button is clicked I am getting the error "type mismatch" when it reaches the line "!amount = CCur(Me.amount)". The code works fine on the XP machines. Is there a workaround to have this work on the Vista machine?

    With rst
    .AddNew
    !ReceiptNo = CLng(Me.ReceiptNo)
    !Date = CDate(Me.ReceiptDate)
    !ClientNo = CLng(Me.Combo37)
    !ClientName = Me.Combo37.Column(1)
    !description = Nz(Me.description, Null)
    !amount = CCur(Me.amount)

    Regards
    Toukey

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    When apps run fine on one machine and not on another or run fine in one version and not when run under a newer version, the first thing you have to think about are missing references. My guess here is that you've installed Access on these new Vista machines and you have one or more missing references.

    Here are Doug Steele's detailed instructions on how to troubleshoot the problem:

    Access Reference Problems
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Sep 2001
    Posts
    175
    Thanks - I will check it out

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Presumably you already have, since I gave you the same link Monday and you said it didn't help. You never addressed whether all the records have a value in the amount field, or if it could be Null.
    Paul

  5. #5
    Join Date
    Sep 2001
    Posts
    175
    Yes - the amount field is always populated.

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Can you post the db?
    Paul

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Try using ! versus . (there's a difference between me.receiptno and me!receiptno even though . works, ! is proper to represent the value of the field while . represents the field itself.)

    ie.
    With rst
    .AddNew
    !ReceiptNo = CLng(Me!ReceiptNo)
    !Date = CDate(Me!ReceiptDate)
    !ClientNo = CLng(Me!Combo37)
    !ClientName = Me.Combo37.Column(1)
    !description = Nz(Me!description, Null)
    !amount = CCur(Me!amount)

    You can also try dimensioning variables and then use the CCur on the variable name.
    ie.
    Dim varAmount as variant
    varAmount = me!Amount
    !amount = CCur(varAmount)
    Last edited by pkstormy; 04-07-10 at 20:49.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Best reference I've seen:

    Microsoft Access : Dot or Bang?
    Paul

  9. #9
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Thanks for the reply Paul. I ended up creating a new post specifically on the subject but I appreciate the link and info. Interesting that it relates that using ! is actually slower (although I never personally timed it).

    I would be curious on the actual difference of the speed using !
    Last edited by pkstormy; 04-07-10 at 21:40.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •