473,320 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Query keeps deleting after using the Docmd.sendobject

VbaNewbee
I have a form, once a button is clicked it sends out an excel email attachment to lotus notes.

The first time it works fine, however ifyou try to attach and send out the attachment again it states the Error "Query must have one destination field"

I then go look at the query it is pulling from and it keeps getting Deleted. I have no idea why it keeps deleting.

Is there a way to send out an email attachment in VBA and hardcode the SQL instead of pulling it through a Access Macro?

THANKS FOR YOUR HELP!
Jul 18 '07 #1
3 2833
MMcCarthy
14,534 Expert Mod 8TB
Moving to Access Forum.

In the meantime can you post the actual code you are using and the sql of the query you are trying to send.
Jul 19 '07 #2
Moving to Access Forum.

In the meantime can you post the actual code you are using and the sql of the query you are trying to send.
___________________________________________
THIS IS THE CODE I USE TO EXPORT THE SPREADSHEET IN AN EMAIL ATTACHMENT
__________________________________________
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command69_Click()
  2. On Error GoTo Command69_Click_Err
  3.  
  4.     DoCmd.SendObject acQuery, "Apt_Requests", "MicrosoftExcelBiff8(*.xls)", "johndoe@gmail.com", "", "johndoe@gmail.com, johndoe@gmail.com,johndoe@gmail.com", "Appointment Request ", "Contents of the email message are IN here", False, ""
  5.  
  6.  
  7. Command69_Click_Exit:
  8.     Exit Sub
  9.  
  10. Command69_Click_Err:
  11.     MsgBox Error$
  12.     Resume Command69_Click_Exit
  13.  
  14. End Sub
__________________________________________________ ______
THIS IS THE CODE I USE TO IMPORT THE SPREADSHEET BACK IN TO A TABLE
__________________________________________________-
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command88_Click()
  2. DoCmd.SetWarnings False
  3.  
  4.     Dim SQL As String
  5.  
  6.    SQL = "delete * from [pickup] WHERE ((([pickup].DC) Is Null))  "
  7.  
  8.   DoCmd.RunSQL SQL
  9. DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel3, "pickup", "U:\REPLIED_CARRIER_APT\Apt_Requests.xls", True, ""
My question, is there a way instead of listing the query name "Apt_requests" in the docmd.sendobject statement to actually write the query sql statement in that docmd.sendobject procedure?

Help so much appreciated.

Thank you!
Jul 19 '07 #3
NeoPa
32,556 Expert Mod 16PB
In answer to your fundamental question, No, only objects (Tables; QueryDefs; etc) can be exported or sent.
Put your cursor on SendObject and hit F1 for the help topic which explains it in more detail.

As far as your QueryDef being deleted (A QueryDef is just the name for a saved query) goes, there is nothing I can see from what you've posted that would account for that. It certainly wouldn't be a natural byproduct of the SendObject function.

If you want further help on that aspect, you will need to post all the relevant code AND the SQL as requested in Mary's post.
Jul 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Alfred | last post by:
Hi I am using access 2002 1.0 I want to email a word or html file using the docmd.sendobject The document must be send as a attachment. 2.0 Second I would like to tell the Docmd.Sendobject to...
2
by: Lumpierbritches | last post by:
Hello, and thank you in advance for any and all assistance. I'm having a problem. This code worked years ago, what am I doing wrong? Private Sub SendeMail_Click() DoCmd.SendObject...
0
by: cronept | last post by:
Hi, there, I have a form with 2 email buttons both with docmd.sendobject code. The 1st one send a report which is working properly. The 2nd one send a query in xls format which is always get an...
2
by: Marcus | last post by:
Is there a way to have Access 2002 open a particular email client, when using DoCmd.SendObject? So far, Access simply opens the default email client that is set under Control Panel/Internet...
4
by: deko | last post by:
When using OutputTo with a query, the 'File name' window in the 'Output To' dialog gets populated with the name of the query by default. This makes the exported file self-describing if the query...
2
by: John Taylor | last post by:
I have created a command button on a form that prints a filtered report and e-mails the report to three people when "clicked". The three email addresses are selected on the form by three combo...
1
by: noel.tock | last post by:
Hi all, Thank you already for the amount of information that has collected in this group, very helpful indeed. I have a question in regards to setting up individual emails to be sent based on a...
25
damonreid
by: damonreid | last post by:
Hey, I am trying to take the results of a query to auto-email people reports only relating to themselves. I can take e-mail addresses from a ListBox and pass them to the SendObject command but I...
20
by: raddrummer | last post by:
Hi there, I'm woking on a function that takes the input from a form (including Payroll Contact), uses it as a query parameter, runs the query, and then emaills out a custom .xls file using the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.