Transfer database (1 Viewer)

ukmale65000

Registered User.
Local time
Today, 19:43
Joined
Nov 28, 2007
Messages
52
Im stuck on a project that I have received help on before. I am trying to E-Mail a daily report created by a macro in Access 2000. It needs to go out as an excel spreadsheet, but in a format that can be opened in a Blackberry. The advise i was given was to use Transferdatabase. This is where i become unstuck. No matter what I type where i come unstuck. Is there anyone out there that can possibly advise me what to do in "idiot proof" steps?
Im afraid my knowledge of Access is limited to 2 weeks self taught knowhow ?
 

rsmonkey

Registered User.
Local time
Today, 11:43
Joined
Aug 14, 2006
Messages
298
does this need to be an automated process or a process controlled by a control on a form? If not just open up the table/query you wanna export to excel and goto File > Export then in the Save As Type dropdown and the bottom just select Excel 2003 or whatever...
 

ukmale65000

Registered User.
Local time
Today, 19:43
Joined
Nov 28, 2007
Messages
52
The code i use (below) is linked to a button on my front page, what happens at the moment is the user is given a check to see if they really want to send a report. If they answer yes, it compiles an E-Mail and sends it automatically. As i said it sends it in excel 95 which is unreadable by Blackberry. I need it to compile and send in Excel 97 or later

Private Sub today1_Click()
On Error GoTo Err_today1_Click


txt_date1.Value = Date - 1 & " 06:00:00"
txt_date2.Value = Date & " 06:00:00"


Dim stDocName As String
Dim Msg, Style, Title, Response, MyString

Msg = "Do you want to send report?" ' Define message.

Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.

Title = "Send Report" ' Define title.

' context.

' Display message.

Response = MsgBox(Msg, Style, Title)

If Response = vbYes Then ' User chose Yes.

stDocName = "daily"
DoCmd.RunMacro stDocName
DoCmd.RunMacro "backup"



Else ' User chose No.

Exit Sub



End If







Exit_today1_Click:
Exit Sub

Err_today1_Click:
MsgBox Err.Description
Resume Exit_today1_Click

End Sub
 

rsmonkey

Registered User.
Local time
Today, 11:43
Joined
Aug 14, 2006
Messages
298
Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "YOURTABLE/QUERYNAMEYOUWANTTOEXPORT", "C:\Filepath\daily.xls"

job done this will export as an 200-2003 excel spreadsheet!

so the if statement will look like this:

Code:
If Response = vbYes Then ' User chose Yes.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "YOURTABLE/QUERYNAMEYOUWANTTOEXPORT", "C:\Filepath\daily.xls"

Else ' User chose No.
     'do nothing

Exit Sub

End If
 

ukmale65000

Registered User.
Local time
Today, 19:43
Joined
Nov 28, 2007
Messages
52
Great

This copies my table to my C drive , but how do I automatically send(email) the object(table) in Excel 97 or higher format

Thanks
 

ukmale65000

Registered User.
Local time
Today, 19:43
Joined
Nov 28, 2007
Messages
52
Great

This copies my table to my C drive , but how do I automatically send(email) the object(table) in Excel 97 or higher format

Thanks
 

ukmale65000

Registered User.
Local time
Today, 19:43
Joined
Nov 28, 2007
Messages
52
Great

This copies my table to my C drive , but how do I automatically send(email) the object(table) in Excel 97 or higher format

Thanks
 

rsmonkey

Registered User.
Local time
Today, 11:43
Joined
Aug 14, 2006
Messages
298
Just change the parameters its pretty clear wats happening....

Code:
Public Sub SendOutlookMessage( _
    strEmailAddress As String, _
    strEmailCCAddress As String, _
    strEmailBccAddress As String, _
    strSubject As String, _
    strMessage As String, _
    blnDisplayMessage As Boolean, _
    Optional strAttachmentFullPath As String)
    
'* Copy this code and paste it into a new Access
'* Module. Click Tools > References and make sure
'* that "Microsoft Office Outlook x.0 Object Library"
'* is checked.
'*
'* This subroutine sends an e-mail message through
'* MS Outlook. If the "blnDisplayMessage" parm is
'* set to "False", the message is placed in the
'* Outlook Outbox. "True" displays the message, and
'* user will have to click "Send" to send it.
'*
'* Ex.:
'*
'* SendOutlookMessage _
'*      "john@doe.com", _
'*      "ccJane@doe.com", _
'*      "bccSue@doe.com", _
'*      "Subject", _
'*      "Body of Message", _
'*      False, _
'*      "C:\My Documents\MyAttachmentFile.txt"
    
Dim objApp As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecipient As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim blnOutlookInitiallyOpen As Boolean
Dim strProcName As String

On Error Resume Next
strProcName = "SendOutlookMessage"

blnOutlookInitiallyOpen = True
Set objApp = GetObject(, "Outlook.Application")
If objApp Is Nothing Then
    Set objApp = CreateObject("Outlook.Application")
    '* Outlook wasn't open when this function started.
    blnOutlookInitiallyOpen = False
End If
If Err <> 0 Then Beep: _
    MsgBox "Error in " & strProcName & " (1): " _
        & Err.Number & " - " & Err.Description: _
    Err.Clear: _
    GoTo Exit_Section

'Create the message
Set objOutlookMsg = objApp.CreateItem(olMailItem)
If Err <> 0 Then Beep: _
    MsgBox "Error in " & strProcName & " (2): " _
        & Err.Number & " - " & Err.Description: _
    Err.Clear: _
    GoTo Exit_Section
    
With objOutlookMsg
    Set objOutlookRecipient = .Recipients.Add(strEmailAddress)
    objOutlookRecipient.Type = olTo
    If strEmailCCAddress = "" Then
    Else
        Set objOutlookRecipient = .Recipients.Add(strEmailCCAddress)
        objOutlookRecipient.Type = olCC
    End If
    If strEmailBccAddress = "" Then
    Else
        Set objOutlookRecipient = .Recipients.Add(strEmailBccAddress)
        objOutlookRecipient.Type = olBCC
    End If
    .subject = strSubject
    .Body = strMessage

    '* Add attachments
    If Not IsMissing(strAttachmentFullPath) Then
        If Trim(strAttachmentFullPath) = "" Then
        Else
            Set objOutlookAttach = .Attachments.Add(strAttachmentFullPath)
            If Err <> 0 Then Beep: _
                MsgBox "Error in " & strProcName & " (3): " _
                    & Err.Number & " - " & Err.Description: _
                Err.Clear: _
                GoTo Exit_Section
        End If
    End If

    If blnDisplayMessage Then
        .Display
    Else
        '* Send message by putting it in the Outbox
        .Send
    End If
End With
    
If Err <> 0 Then Beep: _
    MsgBox "Error in " & strProcName & " (99): " _
        & Err.Number & " - " & Err.Description: _
    Err.Clear: _
    GoTo Exit_Section
    
Exit_Section:
    On Error Resume Next
    If Not blnOutlookInitiallyOpen Then
       objApp.Quit
    End If
    Set objApp = Nothing
    Set objOutlookMsg = Nothing
    Set objOutlookAttach = Nothing
    Set objOutlookRecipient = Nothing
    On Error GoTo 0
End Sub

b/c you cant automate sending the file as an attachment you need to add this module. So as i said paste this code into a module and call that module simply put:

Code:
Call SendOutlookMessage

blah blah blah make sure you change all the paremeters in the code... thats the way i've always done it, alternately:

Code:
DoCmd.SendObject _
    acSendTable, _
    "Table Name", _
    acSpreadsheetTypeExcel9, _
    "ToJohn@doe.com", _
    , _
    , _
    "Type Your Email Subject here", _
    "Type any Email Message Here", _
    False

not sure how well it works though...
 

Users who are viewing this thread

Top Bottom