Code Problems (1 Viewer)

Cosmos75

Registered User.
Local time
Today, 11:44
Joined
Apr 22, 2002
Messages
1,281
I’ve developed a database in Access 97 that works on my computer (Win 2000, Access 97 and Access 2000).

When I brought it over to user’s computer (Win 98 & Access 97) I had a bunch of code that wouldn’t work. It was simple code as well.

Examples with problem bolded;

1. A textbox with this as the Control Source
=Month(Date())

2.TextBox on report
Format([UsageDay],"mmmm - yyyy")
- I think that anywhere I have Format(), it doesn’t work!!

3. Return to new line in MsgBox
- Chr(13) will give an error if I use it to go to the next line in a msgbox. Will have to try vbCrLf or VbNewLine.

4. Button to save a report as a snapshot file
Code:
Dim ReportName As String
Dim ReportDate As String
Dim FileName As String

ReportName = "Report ("
ReportDate = Me.txtMonth & "-" & Me.txtDay & "-" & Me.txtYear & ")"
    
FileName = ReportName & ReportDate
    
Dim sngStart As Variant
Dim sngEnd As Variant
Dim sngElapsed As Variant

‘Get Start Time
sngStart = Timer
stDocName = "rptNewCoatingLetter"

DoCmd.OutputTo acOutputReport, stDocName, "SnapshotFormat(*.snp)",_
[b]Left[/b](CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name)))_
& "Notification Letters\" & FileName & ".snp", True    

‘Get end time.
sngEnd = Timer

' Elapsed time.
sngElapsed = [b]Format[/b](sngEnd - sngStart, "Fixed")

As a side note on #2, there was a problem with =Format$([UsageDay],"mmmm yyyy",0,0) is a textbox on a report on the user’s computer, when they’d try to run the report, it would ask the user to enter the parameter Format$??. Added the MSCAL.ocx (Microsoft Calendar Control 8.0) file and reference fixed that but the date would not show up properly. (Thanks to pdx_man for that tip). I think IT was supposed to register that (via command prompt with regsvr32 Mscal.ocx) but not sure if they ever got to it. I’ll have that checked.

Has anyone come across this problem? I originally developed the db in Acc97 when I had Win98 as my OS so I don’t see a big difference between the computers.

This is the order and file location of the references for my code. The user’s computer also has this order. But keep in mind that the calendar control may not be registered.

Visual Basic for Applications – c:\Program Files\Common Files\Microsoft Shared\VBA\vba332.dll

Microsoft Access 8.0 Object Library – c:\Program Files\office97\Office\MSACC8.OLB

OLE Automation – c:\WinNT\System32\STDOLE2.TLB

Microsoft DAO 2.5/3.51 Compatibility Library – c:\Program Files\Common Files\Microsoft Shared\DAO\DAO2535.TLB

Microsoft ActiveX Data Objects 2.1 Library – c:\Program Files\Common Files\System\ADO\msado21.tlb

Microsoft Calendar Control 8.0 – C:\WinNT\System32\MSCAL.OCX

Snapshot Viewer Control – c:\PROGRA~1\COMMON~\System\SNAPVIEW.OCX


EDIT: I did not use any kind of packaging program. Just copied my files (Split Db) to their computer.
 
Last edited:
R

Rich

Guest
It's almost certainly a missing reference problem
Shouldn't it be Microsoft DAO 3.6 Object Library ?
 

Cosmos75

Registered User.
Local time
Today, 11:44
Joined
Apr 22, 2002
Messages
1,281
Rich,

I did try Microsoft DAO 3.6 Object Library but that didn't work - had problems with the switchboard but Microsoft DAO 2.5/3.51 Compatibility Library works.

Isn't Format(), Month() and Chr(13) for of Visual Basic for Applications?
 
R

Rich

Guest
Can't remember but simply unchecking one reference compiling and saving usually sorts the problem out
 

Cosmos75

Registered User.
Local time
Today, 11:44
Joined
Apr 22, 2002
Messages
1,281
Plan to copy all the reference files I have on my computer to the user's computer and relink the library files to see if that will fix it.

I do have some questions;
1) Does changing the references while the DB file is open on one computer, change the reference for other databases opened on the same computer? How about when it is opened by another computer, wll I have to set the reference paths again?
2) What about after I work out the kinks and save the file as an MDE, will those references be automatically assigned to every computer that opens the MDE?
3) What happens if one computer doesn't have that reference/library file? Or has it in a diferent path?
4) Can I put those reference/library files out on the network in a seperate folder called references? (Bad idea?)

Both the front End and Back end of the db are out on the network, is that a problem?
 

Cosmos75

Registered User.
Local time
Today, 11:44
Joined
Apr 22, 2002
Messages
1,281
Any idea if my ideas (see questions) in the post prior to this will be better to try or if the code in the Knowledge Base Article would be a better solution?

Not quite sure if my ideas are even workable?
:confused:
 

Cosmos75

Registered User.
Local time
Today, 11:44
Joined
Apr 22, 2002
Messages
1,281
Microsoft Knowledge Base Article - 194374
ACC97: Error Message: Function Isn't Available in Expressions in Query Expression
http://support.microsoft.com/default.aspx?scid=KB;en-us;q194374
Code:
Sub FixUpRefs()
    Dim loRef As Access.Reference
    Dim intCount As Integer
    Dim intX As Integer
    Dim blnBroke As Boolean
    Dim strPath As String

    On Error Resume Next

    'Count the number of references in the database
    intCount = Access.References.Count
  
    'Loop through each reference in the database
    'and determine if the reference is broken.
    'If it is broken, remove the Reference and add it back.
    For intX = intCount To 1 Step -1
      Set loRef = Access.References(intX)
      With loRef
        blnBroke = .IsBroken
        If blnBroke = True Or Err <> 0 Then
          strPath = .FullPath
          With Access.References
            .Remove loRef
            .AddFromFile strPath
          End With
        End If
       End With
    Next
    
  Set loRef = Nothing
  
  ' Call a hidden SysCmd to automatically compile/save all modules.
  Call SysCmd(504, 16483)
End Sub
I don't have anyway to test this. If I were to just copy all the reference library files out to a folder on the network drive, would this code look for those files there or would I have to specify their locations somehow in code?

I think can use this code to see the references I have in the currently open database. Does anyone know if this will loop through ALL the refences? I think it does...

Microsoft Knowledge Base Article - 186305
ACC97: How to Loop Through References to View Their Properties
http://support.microsoft.com/default.aspx?scid=kb;en-us;186305&Product=acc97
Code:
    Sub ReferenceInfo()
      Dim strMessage As String
      Dim strTitle As String
      Dim bytButtons As Byte
      Dim refItem As Reference

      On Error Resume Next

      For Each refItem In References
         If refItem.IsBroken Then
            strTitle = "MISSING Reference"
            strMessage = "Missing Reference:" & vbCrLf & refItem.FullPath
            bytButtons = 16 'critical symbol
         Else
            strTitle = "Displaying References and Their Locations"
            strMessage = "Reference: " & refItem.Name & vbCrLf & _
            "Location: " & refItem.FullPath
            bytButtons = 64 'information symbol
        End If

      MsgBox prompt:=strMessage, Title:=strTitle, buttons:=bytButtons

      Next refItem

    End Sub

Some code from WayneRyan - I think this will only change references on the current database and not ALL database files opened on a comupter?

Code:
Private Sub SetRefs_Click() 
Dim ref As Reference 
Dim intRef As Integer 
Dim ErrorMsg As String 

On Error GoTo ErrHandler 

intRef = 1 
Set ref = References.AddFromFile("C:\Program Files\Common Files\_
MicroSoft Shared\VBA\VBA332.DLL") 

intRef = 2 
Set ref = References.AddFromFile("C:\Program Files\MicroSoft Office\_
Office\MSACC8.OLB") 

intRef = 3 
Set ref = References.AddFromFile("C:\Program Files\MicroSoft Office\_
Office\MSO97.OLB") 

intRef = 4 
Set ref = References.AddFromFile("C:\Program Files\Common Files\_
MicroSoft Shared\DAO\DAO360.DLL") 

intRef = 5 
Set ref = References.AddFromFile("C:\Program Files\MicroSoft Office\_
Office\MSPRJ9.OLB") 

intRef = 6 
Set ref = References.AddFromFile("C:\Program Files\MicroSoft Office\_
Office\EXCEL8.OLB") 

Exit Sub 

ErrHandler: 
Select Case intRef 
Case 1 
ErrorMsg = "No VBA332" 
Case 2 
ErrorMsg = "No DAO360" 
Case 3 
ErrorMsg = "No MSACC8" 
Case 4 
ErrorMsg = "No MS097" 
Case 5 
ErrorMsg = "No MSPRJ9" 
Case 6 
ErrorMsg = "No EXCEL8" 
End Select 

MsgBox (ErrorMsg) 

End Sub

Interesting Links
http://members.rogers.com/douglas.j.steele/AccessReferenceErrors.html
 
Last edited:

Friday

Registered User.
Local time
Today, 17:44
Joined
Apr 11, 2003
Messages
542
I had a similar problem last year and fixed it by loading marquee.ocx, but I think I was moving from NT to XP. You might try it, though. I was having trouble with the same code you are referring to.
 

Cosmos75

Registered User.
Local time
Today, 11:44
Joined
Apr 22, 2002
Messages
1,281
Friday said:
I had a similar problem last year and fixed it by loading marquee.ocx...
I would have never thought of that!

Won't be able to test it right away. Is there some code I need to know to load and register references or ocx files?

Seems that it has also plagued a few others.

http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=42506&highlight=marquee.ocx

http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=890&highlight=marquee.ocx
 

Friday

Registered User.
Local time
Today, 17:44
Joined
Apr 11, 2003
Messages
542
I did some digging in my notes, and found where I had done this. It was last year, BEFORE we moved to XP. We had just upgraded a machine in our office to NT Service Pak 6a and IE 6.0 when things started to go wrong, but only on that machine. I had one of the desktop support guys look into it, and he advised it was IE 6.0 that was causing the problem (he alternated loading the two on a machine until he figured out which one caused the problem). Then we found out about the marquee.ocx thing (on here I think). Evidently, when IE 6.0 was installed on the NT machine, it was removing marquee.ocx, possibly 'cause the nimrods at MS felt it was no longer being used (???). Anyway, I put a copy of marquee.ocx in the system folder and the problem went away. Several months later, the problem came back. I checked, and we had put some new software on the machine, which re-installed IE 6.0. Sure enough, marquee.ocx was gone. I recopied it and all was well. Then we moved to XP. Same problem. Same fix.
 

Friday

Registered User.
Local time
Today, 17:44
Joined
Apr 11, 2003
Messages
542
Cosmos75 said:

I would have never thought of that!

Won't be able to test it right away. Is there some code I need to know to load and register references or ocx files?

Seems that it has also plagued a few others.

http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=42506&highlight=marquee.ocx

http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=890&highlight=marquee.ocx

If you look at the first link, the guy who posed that question, dennis g, was my first identity on this forum. Then one day it ceased to work, and I had to create a new name, and lost credit for my first 106 posts...:mad:
 

Users who are viewing this thread

Top Bottom