DTPicker and/or Missing References Generally

darbid

Registered User.
Local time
Today, 15:48
Joined
Jun 26, 2008
Messages
1,428
I am pretty sure I am aware of the problem here - I have a DTPicker date control on a form which requires a reference to at least MSComCt2.ocx.

It seems by chance that my computer had this file so I used the control, but any new computers in our company (they are installed with XP still) do not have this control.

Also randomly MSCOMCTL.OCX is also missing.

I have read things like

http://www.accessmvp.com/djsteele/AccessReferenceErrors.html

http://www.access-programmers.co.uk/forums/showthread.php?t=43921

http://support.microsoft.com/kb/824255

But as microsoft does not seem to give support for it anymore http://support.microsoft.com/kb/297381 This problem will remain.

So as I am distributing a front end (a folder which contains the front end mde and other files) I thought I could simply include these two OCX files in there and all would be good. It seems that this allows my program to start (normally it does not even start) but as soon as you call the form which contains the control it says that the control is missing. (I am assuming this is because it is not registered in this folder)

As far as I can work out I do not have an option of late binding.

Up until now I have done the most written solution which is go to the problem computer and copy the OCX's into C:\WINNT\system32 (i have never needed to register it though) but this solution is not a long term one.

No offence but I prefer not to use the datepicker that has been developed here in the forum.

My first question is that such a control seems normal/essential for access surely when microsoft stopped distributing it, they offered something new. Did they? What is it?

If there is no replacement, then I know the problem, I have the OCX files, how should I make sure when a computer starts my program that does not by default have these files, reference them somehow. Should I simply distribute them with my front end and at start up do a file FILECOPY to C:\WINNT\system32 if the file is not there?
 
Last edited:
I remember having this problem years ago and if my memory serves me right I copied the ocx to the win sys folder then ran regsrver32.exe to register the ocx
 
This has been annoying me for a while and I suppose I just did not want to deal with ocx/dll and registering them bla bla.......

But as I like "window candy" I wanted to make one of those ajax-waiting animated gifs. This forum has one when you do an advanced edit. I am a beginner so my code may not be the best but at this stage it appears to work.

I saw the non-active x solution but thought it was time to get GIF89.dll and make it work.

For the beginners I have/had three problem children MSCOMCTL.OSX, mscomct2.ocx and the problem I introduced GIF89.DLL.

I use a small .exe to save my front end onto another computer and this takes these three files with it. At start up I do the below checks which simply checks to see if these files are where they should be. I am using "windir" because the system32 can be in different places depending on WINNT or XP Pro. If the file is not there, I copy it there.
Code:
If Not Dir(Environ("windir") & "\system32\MSCOMCTL.OCX") <> "" Then
        FileCopy CurrentProject.Path & "\MSCOMCTL.OCX", Environ("windir") & "\system32\MSCOMCTL.OCX"
    End If

If Not Dir(Environ("windir") & "\system32\mscomct2.ocx") <> "" Then
        FileCopy CurrentProject.Path & "\mscomct2.ocx", Environ("windir") & "\system32\mscomct2.ocx"
    End If
    
If Not Dir(Environ("windir") & "\system32\GIF89.DLL") <> "" Then
        FileCopy CurrentProject.Path & "\GIF89.DLL", Environ("windir") & "\system32\GIF89.DLL"
    End If
You then need to register these so that Windows knows about them and puts an entry into the registry. To do this you need a script in .bat which in my language means some code that runs in that black DOS window that you get from start > run > cmd

This calls the .bat file and the "0" at the end makes it hidden to the user.
Code:
Call Shell(CurrentProject.Path & "\reglibs.bat", 0)
The actual .bat file you can create with NOTEPAD. Mine looks like this.
Code:
@echo off
%SYSTEMROOT%\system32\regsvr32 /s %SYSTEMROOT%\system32\GIF89.DLL
%SYSTEMROOT%\system32\regsvr32 /s %SYSTEMROOT%\system32\mscomct2.ocx
%SYSTEMROOT%\system32\regsvr32 /s %SYSTEMROOT%\system32\MSCOMCTL.OCX
I suppose it is very blunt as it registers all of them again but I am not aware of a problem in doing this.
 
I had the same Problems with an VBA-Application in Excel.

On a Form I placed a DTPicker-Control. On some customer machines the OCX-File was not installed. I decided to use Late Binding and place the control on the form programmatically. On failure I place a Textbox wich has the main properties (position-properties and value) in common with DTPicker.

Part of my code:

Code:
Private Sub UserForm_Initialize()
    ' [...]

    '
    ' + late binding of DateTimePicker Control
    '
    
    Dim dtP As Object
    
    On Error Resume Next
    Set dtP = Me.Controls.add("MSComCtl2.DTPicker", "DTPicker1", True)
    
    If Err.number <> 0 Or dtP Is Nothing Then
        hasDtPicker = False
        Set dtP = Me.Controls.add("Forms.TextBox.1", "DTPicker1", True)
    Else
        hasDtPicker = True
    End If
    
    '
    ' formatting properties for both TextBox and DTPicker
    '
    With dtP
        .width = 150
        .height = 18
        .Left = Me.TBX_UHeader.Left
        .Top = Me.TBX_Logo.Top
    End With
    
    '
    ' - late binding of DateTimePicker Control - end
    '
End Sub

In my Project there is no big problem if the date can not be picked in some rare cases. :)
 

Users who are viewing this thread

Back
Top Bottom