replaceall function error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a replaceall function which works on my machine. But on the client
side it gives me an error "ActiveX can't create object". Any help on this
would be appreciated.

Thanks,
RK
 
VB Programmer said:
Hi,

I have a replaceall function which works on my machine. But on the
client side it gives me an error "ActiveX can't create object". Any
help on this would be appreciated.

Thanks,
RK

It's going to be pretty hard to debug your problem without seeing the
code. How about posting it? It would also help if you indicate which
line of code raises the error.
 
I've also tried opening a blank access project. In the immediate window I
typed replaceall("test","d","t") and it gave me the same error message.
However, I've discovered that on the client machines they only have read &
execute permissions on their C drive and access is installed on C. Do you
think this could be causing the problem?

Thanks,
RK
 
VB Programmer said:
I've also tried opening a blank access project. In the immediate
window I typed replaceall("test","d","t") and it gave me the same
error message. However, I've discovered that on the client machines
they only have read & execute permissions on their C drive and access
is installed on C. Do you think this could be causing the problem?

Potentially. Since you've given us no idea what your function does, and
not shown any of its code, I really can't say. If you're using the
wizards in this function, some of them make changes in the special
"wizard database" that is installed with Access; that could be a
problem. I've never tried to run Access from a read-only installation.
 
I'm using this function in a bulk email form which allows personalization
within the bulk email somewhat like the mailmerge in Word. In the email
message users can choose to insert field contents which are put in between $$
signs. Eg - $$Lastname$$ would insert the recipients lastname into the
message. Hence I am using replaceall to look for words between two $$ signs &
replace them with the contents of a field. Once again I'd like to say that at
this point even a simple replaceall("test","d","t") gives me the same error
message. In fact using this in a blank database also gives me the same error.
What do you mean by using wizards in this function? How do I do that?

Dim sBaseMessage As String
Dim sActualMessage As String
Dim sFieldToReplace As String
Dim sFieldPosition As Integer
Dim sTempReplace As Variant
Dim replaceflag
Dim StartPos As Integer
Dim EndPos As Integer

Set cnn = CurrentProject.Connection

sBaseMessage = txtMessage


Set rs = New ADODB.Recordset
rs.Open Source:="StudentEmail", _
ActiveConnection:=cnn, _
CursorType:=adOpenDynamic, _
LockType:=adLockOptimistic
rs.MoveFirst

While Not rs.EOF

sActualMessage = sBaseMessage

While InStr(sActualMessage, "$$")
sFieldPosition = InStr(sActualMessage, "$$")
sEndFieldPosition = InStr(sFieldPosition + 1,
sActualMessage, "$$")
sFieldToReplace = Mid$(sActualMessage, sFieldPosition + 2,
sEndFieldPosition - (sFieldPosition + 2))
'sActualMessage = ReplaceAll(sActualMessage,
DLookup(sFieldToReplace, "student_Email", "student_ID=" &
CStr(rs("student_id"))), "$$" & sFieldToReplace & "$$")
sTempReplace = IIf(IsNull(rs(sFieldToReplace)), "Blank",
rs(sFieldToReplace))
sActualMessage = ReplaceAll(sActualMessage,
CStr(sTempReplace), "$$" & sFieldToReplace & "$$")
Wend

If chkTestMode.Value = False Then

nSendFlag = SendEmail(rs("Student_Last_name"),
rs("Student_First_name"), txtFrom, Trim(rs("student_Email")), sActualMessage,
txtSubject)

Else

If MsgBox("TO: " & rs("Student_Email") & vbCrLf & vbCrLf & _
"SUBJECT: " & txtSubject & vbCrLf & vbCrLf & _
sActualMessage & vbCrLf & vbCrLf & "Click OK to continue or
CANCEL to exit test mode.", vbInformation + vbOKCancel, "Test Mode Message
Display") = vbCancel Then
cmdCancel.Tag = "stop"
End If
End If

If cmdCancel.Tag = "cancel" Then
Command24.Caption = "Send"
nSendFlag = SendEmail(rs("Student_Last_name"),
rs("Student_First_name"), txtFrom, txtFrom, "You cancelled this operation
before it completed. However, before it was cancelled, the message was sent
to the following recipients: " & sMailStatus, "Census bulk email report for:
" & txtSubject & " (Cancelled by user)")
MsgBox "The group email has been cancelled.",
vbInformation
cmdCancel.Tag = ""
If InvalidFound = True Then DoCmd.OpenReport
"InvalidEmail", acViewPreview
Exit Sub
End If

If cmdCancel.Tag = "stop" Then
Command24.Caption = "Send"
MsgBox "Test mode has been exited. To send your email,
turn off test mode and click the Send button again.", vbInformation
cmdCancel.Tag = ""
If InvalidFound = True Then DoCmd.OpenReport
"InvalidEmail", acViewPreview
Exit Sub
End If

DoEvents
Command24.Caption = rs("Student_Email")
rs.MoveNext
Wend

rs.Close
If chkTestMode.Value = False Then
nSendFlag = SendEmail("", "", txtFrom, txtFrom, "Your message
was sent to the following recipients: " & sMailStatus & vbCrLf & vbCrLf &
"The following could not be sent: " & sNoMailStatus, "Accessibility bulk
email report for: " & txtSubject)
MsgBox "Your message has been sent.", vbInformation
Else
MsgBox "Test mode has been exited. To send your email, turn off
test mode and click the Send button again.", vbInformation
End If
'End If
Else
If chkTestMode.Value = False Then
nSendFlag = SendEmail("", "", txtFrom, txtTo, txtMessage, txtSubject)
MsgBox "Your message has been sent.", vbInformation
Else
MsgBox "There is no test mode for sending mail to a single
recipient.", vbInformation
cmdCancel.Tag = ""
Exit Sub
End If
End If

Command24.Caption = "Send"

cmdCancel.Tag = ""
DoCmd.Close

End Sub
 
VB Programmer said:
I'm using this function in a bulk email form which allows
personalization within the bulk email somewhat like the mailmerge in
Word. In the email message users can choose to insert field contents
which are put in between $$ signs. Eg - $$Lastname$$ would insert the
recipients lastname into the message. Hence I am using replaceall to
look for words between two $$ signs & replace them with the contents
of a field. Once again I'd like to say that at this point even a
simple replaceall("test","d","t") gives me the same error message. In
fact using this in a blank database also gives me the same error.
What do you mean by using wizards in this function? How do I do that?

I don't know, because you *still* haven't posted the code for the
function ReplaceAll, which -- from what you say -- is the point of
failure. I'm assuming that when you say "using this in a blank database
also gives me the same error", you mean that the database was blank
except for the module you would have had to add, to define the
ReplaceAll function. How did you test it? By entering

?replaceall("test","d","t")

in the Immediate Window?

On the other hand, if you're getting this error no matter *what*
function you call, I have to suspect a problem with your project's
references. On the computer(s) where it fails, check out the references
following Doug Steele's instructions as posted here:

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

As a side note, not directly related to this problem, these lines in the
code you posted:
rs.Open Source:="StudentEmail", _
ActiveConnection:=cnn, _
CursorType:=adOpenDynamic, _
LockType:=adLockOptimistic
rs.MoveFirst

.... will raise an error if the recordset contains no records. You don't
really need that call to rs.MoveFirst in this context, so you can just
delete the line:
 
I'm getting the impression that perhaps 'VB Programmer' is not aware that
'replaceall' is not a built-in function?
 
Back
Top