Problems with Chr() and Date() functions (broken refs)


Question

I created a test data application using Access97 under Windows 95--no problems. I recently changed OS to NT 4.0 (Service Pack 3). When I run the application now I encounter a couple of problems that weren't present under Win95:

1. On a form and on several reports I use concatenated strings to display address info in a text box. To achieve the spacing I want, I use Chr(10) and Chr(13) functions. No problem under Win95, but now my text boxes display the classic "#Name?" error. When I remove the Chr() functions from my strings, all is well (except that my returns and linefeeds are gone). When I edit the text boxes to include Chr() functions, I am presented with the following error: "The function you entered can't be used in this expression."

2. I use the following expression in a query to calculate ages-- Age: DateDiff("yyyy",[Date of Birth],Date()). Again, this worked swimmingly under Win95, but now Access balks with this error: "Function isn't available in expressions in query expression 'DateDiff...'" If I replace Date() with Now(), all is well.

Your suggestions on the source of these problems and how to resolve them are welcomed.

Answer

From: Shamil Salakhetdinov <shamil@marta.darts.spb.ru>
To: Microsoft Access Database Discussion List <ACCESS-L@PEACH.EASE.LSOFT.COM>
Subject: Re: Access97: Problems with Chr() and Date() functions
Date: 22 April 1998 13:02

IMHO, this is a side effect of broken(missing) references not Unicode problems. Very probably on NT you don't have some libraries/activeXs which are presented on your Win95 installation (BTW when you do development under Access97 you usually use 3 standard libraries: VBA,Access and DAO and maybe MS Office 8.0 Object Library if you manipulate commandbars using VBA)

Check references under WinNT - I'm quite sure one or more is/are missing. Maybe this code helps you:

Public Function AppRefsEnum() As Boolean
    Dim ref As Reference
    
    For Each ref In References
       Debug.Print "Name = " & ref.Name & _
                   ", FullPath = " & ref.FullPath & _
                   ", IsBroken = " & CStr(ref.IsBroken)
    Next
End Function

Public Function AppBrokenRefRemove() As Boolean
    Dim ref As Reference
    Dim strRefName As String
    
    For Each ref In References
       If ref.IsBroken Then
          strRefName = ref.Name
          If MsgBox("Broken reference " & strRefName & " will be removed.@" & _
                    "Are you sure you'd like to remove this reference?@", _
                    vbQuestion + vbYesNo + vbDefaultButton2, _
                    "Please approve reference removal") = vbYes Then
             References.Remove ref
             Debug.Print "Reference removed - " & strRefName
             
          End If
       End If
    Next
    
End Function

HTH,
Shamil


HOME    TOPICS

Copyright © 1998–1999 by Shamil Salakhetdinov.
All rights reserved. Terms of use.

Last updated: October 10, 2006

Published also here at 4TOPS: Problems with Chr() and Date() functions (broken refs)