Help. db works on one computer and not another

MichelleB

Registered User.
Local time
Tomorrow, 06:42
Joined
May 29, 2012
Messages
17
Hi i have a script that creates an email for weekend bookings confirmation for musicians. it works perfectly on my computer and worked fine on my other computer till just recently and now it brings up error "13" when i try and run the object?

the code is as follows and seems to be an issue when it actions the outlook.

i just dont understand why it works on mine and not the other computer? please help. it errors on the line Set objMailItem = objOutlook.CreateItem(olMailItem)

:banghead:

Code:
Private Sub Command234_Click()
Dim msgTxt As Variant
Dim objOutlook As Outlook.Application
Dim objMailItem As Outlook.MailItem
Dim blnCreated As Boolean
Dim act As String
Dim venue As String
Dim start As String
Dim finish As String
Dim venuefee As String
Dim bookingfee As String
Dim venuepayment As String
Dim gigdate As String
Dim venue_email As String

strEmail = "bookings@gigs.com"
strSubject = "New Booking Confirmation - "
strBody = "<h2><b>A new booking has been confirmed</b></h2>"
act = Me.artist
gigdate = Format(Me.gigdate, "dddd dd mmmm yyyy")
venue = Me.venuename
start = Format(Me.start, "hh:nn am/pm")
finish = Format(Me.finish, "hh:nn am/pm")
venuefee = Me.venuefee
bookingfee = Me.bookingfee
commission = Me.commission
venuepayment = Me.venuepayment
taken = Me.takendate
venue_email = Me.venue_email


blnCreated = False

Set objOutlook = New Outlook.Application

If IsNull(Me.venue_email) = True Or Me.venue_email = "" Then
DoCmd.Hourglass False
msgTxt = MsgBox("Unable to create an email for " & Me.act & Chr(13) & "No email address listed in the database.", vbOKOnly + vbInformation, "")
Else
DoCmd.Hourglass True
[B]Set objMailItem = objOutlook.CreateItem(olMailItem)[/B]

With objMailItem
.To = Me.venue_email
.CC = strEmail
.Subject = strSubject & " " & venue & " on " & gigdate & " - " & act
.HTMLBody = strBody & "<p>" & "<p>" & act & "<br>" & gigdate & "<br>" & venue & "<br>" & start & " - " & finish & "<br>" & "$" & venuefee & "<p>" & "Payment Details: " & venuepayment & "<p>" & "Please reply OK to confirm this booking" 


.Save
' .Send
blnCreated = True
End With

End If

If blnCreated Then
msgTxt = MsgBox("Finished creating email. The email is in your Outlook 'Drafts' folder.", vbOKOnly, "")
Else
msgTxt = MsgBox("Email Failed.", vbOKOnly, "")
End If

DoCmd.Hourglass False
End Sub
 
Perhaps because your has the Reference to Outlook and the other does not?
 
sorry i do not understand, what am i doing wrong please
 
IT was working fine on both computers then just stopped working on one for no reason that i can trace?
 
You are using Early Binding so you need to set the Reference to Outlook. While the below shows you how to repair a Reference it will show you how to get to that section. When you get there look for the appropiate Microsoft Outlook Reference and check it then try your code again...

http://www.access-diva.com/d5.html

If that doesn't work, try opening Outlook.
 
What would make a computer work fine with this and then just stop? i cannot find reference issues with this, it looks the same on both computers?
 
An update could have been applied that changed something that knocked out your References. A coding change OR the universe collided... Honestly, without knowing what changed with the database, the computer and/or Windows I cannot say for sure. Sorry I could not give you a definitive answer...
 
I have no idea why you have a problem, nor do I think my suggestion below will solve it but are you getting an Outlook object?

Can try this

replace this
Code:
Set objOutlook = New Outlook.Application

with this

Code:
Dim oNS As Outlook.Namespace

On Error Resume Next

 
Set objOutlook = GetObject(, "Outlook.Application")


If Err.Number = 429 Then
    Err.Clear
    Set objOutlook = CreateObject("Outlook.Application")
    Set oNS = objOutlook.GetNamespace("MAPI")
    oNS.Logon "", "", False, True
End If

The oNS is optional any you can just comment that out.
 

Users who are viewing this thread

Back
Top Bottom