Page 1 of 3 123 LastLast
Results 1 to 15 of 39
  1. #1
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    In a function to provide one or two character day abbreviations, the statement

    Abbrev = Left(Format(d,

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    Whatever the message, you may have some other problem in Access2000, I was able to run that first equation fine in Access2000.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    Do you have both 2000 and 2002 installed on the same machine?

    I wonder if this could be the cause, as I found that having 97 and 2000 installed on the same machine produced funny things like this also.

    Jayden

  4. #4
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    Nope, 2002 on one 2000 on another.

    This was found by my partner on a third machine, which has only 2000 also.

  5. #5
    Star Lounger
    Join Date
    Dec 2001
    Location
    Birmingham, Alabama USA
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    I have tested the expression on my machine. I have Access 97, 2000, and 2002 installed and it works in all versions. Only problem I can see is that you are using a "constant" as a variable name. "d" is a constant for "Day" in Access and could very well be confusing Access into producing the error message you are receiving.

    RDH
    Ricky Hicks
    Microsoft MVP
    Birmingham, Alabama USA

  6. #6
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    No, 'd' is not a constant. I shortchanged you as far as the function goes. Here it is complete:
    <pre>Public Function DayOfWeekAbbrev(d As Date) As String
    ' return one or two chars to indicate the day of the week

    Dim wd As VbDayOfWeek ' weekday, per vba conventions
    wd = Weekday(d)

    Dim s As String ' bypasses bug in "Left(Format(d,"ddd"),1)
    s = Format(d, "ddd")

    Select Case wd
    Case vbMonday, vbTuesday, vbWednesday, vbFriday ' single letter abbrev
    DayOfWeekAbbrev = Left(s, 1)
    Case vbSunday, vbThursday, vbSaturday ' two char abbrev
    DayOfWeekAbbrev = Left(s, 2)
    Case Else
    ' can't happen
    DayOfWeekAbbrev = ""
    End Select
    End Function
    </pre>


  7. #7
    Star Lounger
    Join Date
    Dec 2001
    Location
    Birmingham, Alabama USA
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    Well I guess it's all personal preference .... but I would never declare a variable name of a Date/Time datatype "d". I have seen Access confused by much less of my years of programming.

    Anyway .... here is another function I quickly wrote that will do the same thing as yours without all the lines:

    Public Function fDayAbbrev(dtEntry As Date) As String
    Select Case WeekDay(dtEntry)
    Ricky Hicks
    Microsoft MVP
    Birmingham, Alabama USA

  8. #8
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    I notice that you have used the values (2,4,6) etc, instead of using vbMonday etc.

    Just a small point that I thought that I would comment on.

    This isn't the best thing to do, because it isn't guaranteed that later versions of Access will have the weekday function that returns the value for Monday evaluate to 2 - but it should always evaluate to the vbMonday constant. This is why MS include these types of constants.

    Cheers

    Jayden

  9. #9
    Star Lounger
    Join Date
    Dec 2001
    Location
    Birmingham, Alabama USA
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    Maybe it was a mistake on my part to get involved in this thread. I have just tested the function again and can not find where it errors. The only thing I see is that I have Tuesday being calculated as "TU" instead of "T". I thought that it may keep someone from confusing "T" with Thursday. As far as the "integers" ... I have no problem knowing that the WeekDay() function returns an integer from 1 to 7. I have been programming in Access for almost 8 years and have seen Access get "sideways" by many things that can drive you completely nuts. I have only been a member here at this site for a short time but that does not mean I'm "New" at Access. I am a Moderator/Editor at A3 Forums (Access All Areas) and have answered many thousands of questions about Access at many sites. This is not to say that I can not be wrong (I have been wrong many times). I am very sorry if I offended you with my reply and will not respond further to this thread.

    RDH
    Ricky Hicks
    Microsoft MVP
    Birmingham, Alabama USA

  10. #10
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    I take no offense at any of your remarks. The mistake is the statement "will do the same thing as yours".

    Jayden makes the cogent point that Weekday()'s return value may change in the future. If this does happen, altho I would expect the possibility to be very low, code that relies on an out-of-date distribution of integers would break, quietly, and the debugging of that problem would be a fierce challenge.

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    As you know quite well, VBA can tell what a variable is from the declaration. However, most of us have discarded the old single-letter variable names for self-documenting variable names, regardless of the length of the routine. That is entirely a matter of personal preference and programming style. I do agree that using the built-in constants is preferable to hard coding their numeric equivalents, although of course you must use the numeric equivalents in queries.

    The fact is that the function you posted *works* in Access 2000 as well as in Access 2002. Mark tested it, and I tested it as well, pasting your code in to a module in A2k and running it. It is NOT an Access 2000 problem. Access isn't "screwing around with good code and crashing" on our machines, so you need to look elsewhere for your problem.

    We can all understand your frustration because we've all experienced similar situations. However, please be sure your replies to other posters remain courteous.
    Charlotte

  12. #12
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    If VBA cant tell that d as Date defines the variable concisely, and as accurately as anything more verbose, then we are looking at a disaster. Of course, it CAN tell, and in a scope of 16 lines or so, a one-character variable name is entirely adequate.

    Unfortunately, your function does NOT do the same thing as mine: it gets the abbreviations wrong, and one cant tell for what days they are wrong. You would've been better off using the built-in "day symbols" rather than integers, since VBA makes them easy to include with their "Intellisense"

  13. #13
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    You wrote:
    >>What IS bad is Access screwing around with good code and crashing.<<

    The reality of the situation is that if your problem can not be reproduced anywhere else, then it appears it has to be related to the configuration on your machines. When the code failed on the 3rd machine, where they running a database compiled on your machine under Access2002? What happens if they recompile, does problem go away?

    If all else fails, how about creating another database in Access2002 and include nothing else but a module containing your original function (the one that failed). If that also fails on all machines, then append it to your next message so we can try it.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  14. #14
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    I've tried to eliminate the machine as a variable. It's plain vanilla Win2k pro. Office 2000 uninstalled, then OXP installed. Clean. Dell 450MHz PIII. This should be an ideal setup for Access development, as it is for other tools. (Altho a mite slow, these days.) I have not tweaked anything, there are no Access Add-Ins. It's the straight deal.

    The app was compiled on that machine, tried on machine 2 (A2K on Win2K). It halted on the Format function with a msg about a missing library!? Recompiled in A2K on that machine, still failed. Tried on machine 3 (A2K, win98), halt on Format function. Jiggle the code on machine 3, it compiles and works. Recode on machine 1 in AxP, it runs everywhere. I conclude at this point that there is a difference in the two compilers. I also conclude that the simpler the code, the better.

    That test case is a good idea - i'll try it.

    I am guessing that access compiler works something like this: it has a single file in which it keeps both source and compiled code. These are maintained by pointers. With a simple database, ie, with one module, the pointers should be fairly straightforward. With heavy editing, and a couple of forms, i *presume* that the pointers sometimes get clobbered. When that happens, Acc goes down. Predicting the outcome of a simple test, then, I would guess that the error will not show up (*crosses fingers*).

  15. #15
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Found: 2000 / 2002 incompatability (AXP 10.2627.2625)

    Let me suggest another test - I had a somewhat similar situation a couple of days ago. Take the version that you created with XP to the 2000 PC. Then import all the objects into a new clean DB using 2000 and try compiling the database. I believe there is some obscure behavior in XP that causes databases to either end up with missing references of some sort, or actually crash as I had, when you try to run the same database on 2000. Very frustrating, and you suspect that MS must know something abou it.
    Wendell

Page 1 of 3 123 LastLast

Posting Permissions

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