PDA

View Full Version : Variable Uses an Automation Not Supported by VB



danitrin
11-23-2005, 08:54 AM
I have an Access 97 database that is networked and used by about 20 users. Some of the users have NT 4.0 and others have Windows 2000. Two of the NT users receive the following error when attempting to use an email automation form in the database "Variable uses an automation not supported by VB." The code in the database has not changed, and all of the references appear to be intact. This just suddenly quit working for these two users and I have not been able to determine what the problem is. Any suggestions??:dunno

MikeWolfeJr
11-23-2005, 11:21 PM
Ok, this is a little bit of a tricky one.

First, some general troubleshooting notes:
If the app didn't change, then something on the client PC's did. Perhaps another app got installed and replaced or up/downgraded a related DLL.

The other thing to try is logging on those two PC's as another user to see if it is user profile related. I've seen some really odd things happen with user profiles. If another UserID works, then the answer is to wipe-out the failing user's profile (ntuser.dat).

One really fascinating issue I've found recently is if your error handling isn't quite right, and a particular user has VBE's option to "Break on all errors" turned on (as opposed to "break on unhandled errors"), very odd things can happen, like getting errors that other users don't get.

Why this error happens:
Basically, it's a string datatype issue between VB and C++. The bug has always been there in your app, but for some reason it is handled in some cases.

Possible Cause: Early Binding
Dim myControl As New WhateverItIs
Possible Solution: Use late binding
Dim myControl as Object
Set myControl = New WhateverItIs

Possible Cause: Optional variant argument default value
Function MyProc(optional vnt as variant = Something)
Possible Solution: Variant arguments shouldn't have default values
Function MyProc(optional vnt as variant)
If IsMissing(vnt) Then
vnt = Somthing
End If

Possible Cause: Improper "nullification" of string
Function MyProc(Optional myString As String = vbNull)
Function MyProc(Optional myString As String = Null)
Function MyProc(Optional myString As String = Empty)
Possible Solution: Use vbEmpty
Function MyProc(Optional myString As String = vbEmpty)

vbNull is actually &h01
vbEmpty is &h0

Hope that helps, or at least points you in the right direction!

danitrin
11-28-2005, 09:30 AM
Nothing on their pc's have changed, or so I am told by IT. I tried logging under a different profile and received the same results. All the users are set at "break in class module". None of the other possible causes seem to fit, except for maybe early binding. However I'm new to programming so, I not real clear on how that works. Any other suggestions??


Here's a code snippet, the error occurs once the Yes button is clicked on the warning message:

Private Sub cmdSendEmail_Click()
On Error GoTo Err_cmdSendEmail_Click
Dim stDocName As String

Dim strCustomer As String
Dim strEmail As String
Dim strMessage As String
Dim strSubject As String
Dim blnDeleteSent As Boolean
Dim blnDisplayMsg As Boolean
Dim blnReadReceipt As Boolean
Dim strEmailCC As String
Dim strBSOname As String
Dim strDate As String
Dim intResponse As Integer
Dim strCollateral As String
Dim strIneligible As String
Dim strProcessingMessageID As String



intResponse = MsgBox("WARNING: This process will send an email to the client." & vbLf & _
"Do you wish to coninue?", vbYesNo, "Processing Notice")
If intResponse <> vbYes Then
MsgBox "Processing Notice has been cancelled.", vbOKOnly
Exit Sub
End If
'Preview email message prior to sending if box is checked
If chkPreviewEmail = True Then
blnDisplayMsg = True
Else
blnDisplayMsg = False
End If

'Request read receipt to be sent if box is checked
If chkReadReceipt = True Then
blnReadReceipt = True
Else
blnReadReceipt = False
End If

'Send email but only save in Sent messages if box is checked on
If chkSaveSentMessage = True Then
blnDeleteSent = False
Else
blnDeleteSent = True
End If


strCustomer = cbocustomer.Column(1)
strEmail = [Primary Email]
strEmailCC = [Secondary Email]


SendEmail blnDisplayMsg, blnDeleteSent, blnReadReceipt, strCustomer, strEmail, strEmailCC, _
strSubject, strMessage