From: isobadd on
In my department, we have new employees who get the departmental A2k3
application thru a "Q Setup" Install program. When the app is being
installed and opened, there is code within which is supposed to check
to see if the ‘DatePicker’ control (mscomct2.ocx) is present and
‘connected’ to its location in the Windows System32 directory. If
that control is not present or 'connected', the code is supposed to
connect the 'DatePicker'. I have found that it isn’t working because
the new employee is getting a “missing reference” error. Since the
code isn’t working, I have to navigate to ‘Code-->Tools-->References'
and either find the “Missing” checkbox or "Browse” to the Windows
System32 folder and select it to get the DatePicker ‘connected and
cancel the error message. My post is a request for assistance in
trying to determine why the following code isn’t working:

-----------------------------

Public Sub SetReferences()
On Error GoTo Err_SetReferences
Dim ref As Reference
Dim Myflag1 As Boolean
Dim Myflag2 As Boolean
Myflag1 = False
Myflag2 = False

For Each ref In References
If ref.Name = "Mscomctl2" Then
Myflag1 = True
End If
If ref.Name = "MSCOMCTLLib" Then
Myflag2 = True
End If
Next ref

If Not Myflag1 Then
References.AddFromFile "C:\WINDOWS\system32\Mscomct2.OCX"
End If

If Not Myflag2 Then
References.AddFromFile "C:\WINDOWS\system32\MSCOMCTL.OCX"
End If

Exit_SetReferences:
Exit Sub

Err_SetReferences:
MsgBox Err.Description, vbInformation, Me.Caption
Resume Exit_SetReferences

End Sub

---------------

Thanks for your help…
Earl
From: Marco Pagliero on
On 6 Mrz., 16:03, isobadd wrote:
> In my department, we have new employees who get the departmental A2k3
> application thru a "Q Setup" Install program. When the app is being
> installed and opened, there is code within which is supposed to check
> to see if the ‘DatePicker’ control (mscomct2.ocx) is present and
> ‘connected’ to its location in the Windows System32 directory. If
> that control is not present or 'connected', the code is supposed to
> connect the 'DatePicker'. I have found that it isn’t working because
> the new employee is getting a “missing reference” error. Since the
> code isn’t working, I have to navigate to ‘Code-->Tools-->References'
> and either find the “Missing” checkbox or "Browse” to the Windows
> System32 folder and select it to get the DatePicker ‘connected and
> cancel the error message.
I have no direct answer to your question, but if I were to debug this
thing I would consider these possibilities:

1) Acces is checking all references before it executes any code at
all. In this case there is no solution.

2) The mdb starts something that references the ocx before it starts
the code. In this case you have to move things around to avoid this
sequence.

3) The names are wrong, that is "Mscomctl2/Mscomct2.OCX" and
"MSCOMCTLLib/MSCOMCTL.OCX" do exist and are registered, but they do
not contain the control you used. I don't think this is the case, you
have certainly checked this already.

4) The IF doesn't work. I would anyway write "If Myflag1=false then"
instead of "If Not Myflag1 then".

So I would put a "Msgbox Myflag1 & " - " & Myflag2" between "Next ref
" and "If Not Myflag1 Then".

If you see the error message before the message box, you have case 1
or 2.
If Myflag 1 and 2 are true, but the error message comes, you have case
3.
If Myflag 1 and 2 are false but the error message comes, you have
possibly case 4. Or one or both "References.AddFromFile" is not
working, but this should throw an error. You can try and let them both
execute outside the IF, that is always. This would clarify the point.

Hope it helps

Greetings
Marco P
From: Salad on
isobadd wrote:
> In my department, we have new employees who get the departmental A2k3
> application thru a "Q Setup" Install program. When the app is being
> installed and opened, there is code within which is supposed to check
> to see if the �DatePicker� control (mscomct2.ocx) is present and
> �connected� to its location in the Windows System32 directory. If
> that control is not present or 'connected', the code is supposed to
> connect the 'DatePicker'. I have found that it isn�t working because
> the new employee is getting a �missing reference� error. Since the
> code isn�t working, I have to navigate to �Code-->Tools-->References'
> and either find the �Missing� checkbox or "Browse� to the Windows
> System32 folder and select it to get the DatePicker �connected and
> cancel the error message. My post is a request for assistance in
> trying to determine why the following code isn�t working:
>
> -----------------------------
>
> Public Sub SetReferences()
> On Error GoTo Err_SetReferences
> Dim ref As Reference
> Dim Myflag1 As Boolean
> Dim Myflag2 As Boolean
> Myflag1 = False
> Myflag2 = False
>
> For Each ref In References
> If ref.Name = "Mscomctl2" Then
> Myflag1 = True
> End If
> If ref.Name = "MSCOMCTLLib" Then
> Myflag2 = True
> End If
> Next ref
>
> If Not Myflag1 Then
> References.AddFromFile "C:\WINDOWS\system32\Mscomct2.OCX"
> End If
>
> If Not Myflag2 Then
> References.AddFromFile "C:\WINDOWS\system32\MSCOMCTL.OCX"
> End If
>
> Exit_SetReferences:
> Exit Sub
>
> Err_SetReferences:
> MsgBox Err.Description, vbInformation, Me.Caption
> Resume Exit_SetReferences
>
> End Sub
>
> ---------------
>
> Thanks for your help�
> Earl

You could look at this link for some pointers.
http://www.tek-tips.com/viewthread.cfm?qid=903662
Look for FixUpRefs() there.