Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Dec 2002
    Location
    Bruges, Belgium
    Posts
    122
    Thanks
    14
    Thanked 2 Times in 2 Posts

    Acces VBA Data Type (2003)

    Following code used to update an access table ends with an -21472178664 (80040e38) error: I strongly suspects that it has something to do with confilicting data types between access and VBA.

    With rsXR
    .MoveFirst
    Do While Not .EOF
    Dim strXRate As String
    strXRate = SearchXRate(!CurCode, strWebPage)
    Select Case strXRate = c_strNotFound
    Case True
    'do nothing - no update
    Case False
    !XRate = CDec(strXRate)
    End Select
    .Update
    .MoveNext
    Loop
    End With


    SearchXRate is a function that searches a given Web Page and returns an Exchange Rate as a string

    The Recordset is defined as follows:

    With rsXR
    .ActiveConnection = CurrentProject.Connection
    .CursorLocation = adUseClient
    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
    .Source = c_strQryXRate
    .Open options:=adCmdText
    End With


    The program bumps on the Update statement. The database field XRate is defined as Decimal Fixed, Precision=15, Scale & Decimal Places =5

    What is VBA equivalent? How to perform the Update?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Acces VBA Data Type (2003)

    Decimal is not a native Access data type. Try changing it to (Number, ) Double or Single, and use the corresponding conversion function (CDbl or CSng) in the code.

  3. #3
    2 Star Lounger
    Join Date
    Dec 2002
    Location
    Bruges, Belgium
    Posts
    122
    Thanks
    14
    Thanked 2 Times in 2 Posts

    Re: Acces VBA Data Type (2003)

    Thanks HansV. Does this mean that I should avoid declaring fields as decimal? Are there other non-native data types for access (i.e. that have no equivalent counter part in VBA)?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Acces VBA Data Type (2003)

    Yes, you should avoid defining fields as Decimal.

    As far as I know, Decimal is the only field size offered in the standard dropdowns that shojld be avoided. It's meant for compatibility with SQL Server.

Posting Permissions

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