SendObject link criteria problem

BarryMK

4 strings are enough
Local time
Today, 20:09
Joined
Oct 15, 2002
Messages
1,350
I have the following piece of code to fire off an email on closing a new record. How can I fit in the link criterion of PK field txtOrderID to the DoCmd.SendObject line so that it will link to the current record? I would normally put '& Me.txtOrderID' in the space now occupied by 'strSubject'. I've tried several variations with " and & etc but so far no joy....


Dim strBody As String, strSubject As String

DoCmd.RunCommand acCmdSaveRecord

strSubject = "You have received a new Purchase request."
strBody = "A purchase request has been added by " & Me!txtRequester & ". Record number " & Me!txtOrderID & ". The supplier is " & Me!txtSupplier & ". The product is " & Me!txtProduct & ". Cost per item is £" & Me!txtCost & ". Product number/code is " & Me!txtCatnumber & ". Quantity is " & Me!txtQuantity & ". Total cost is £" & Me!txtTotalcost & ". Approve by forwarding to finance for action or to sender to reject"


DoCmd.SendObject , , , "access.baffled@isp.com ", , , strSubject, strBody, True
 
What happens if you simply put:

DoCmd.SendObject , , , "access.baffled@isp.com ", , , strSubject & Me.txtOrderID, strBody, True
? Please give details of any error message you get.

Keith.
 
Hi Keith

No error message it just puts the field content from the first record into the email body. I've also tried stLinkCriteria syntax 'stLinkCriteria = "[txtOrderID]=" & Me![txtOrderID]' awith the same result. It seems the strSubject entry blocks the linking action.
 
OK, I must admit I thought that was what you were trying to achieve. I don't understand what you mean by the "link criterion", so please post more details.

Thanks,
Keith.
 
KeithWilliams said:
OK, I must admit I thought that was what you were trying to achieve. I don't understand what you mean by the "link criterion", so please post more details.

Thanks,
Keith.


Using SendObject to send a report containing the record I'm looking at on my form I would use & Me!txtOrderID as the criterion that selects the primary key of the record I wish to mail as below:

DoCmd.SendObject acSendReport, stDocName, acFormatRTF, "access.baffled@isp.com", ", , "My subject here" & Me!txtOrderID

The code I originally posted allows me to place the actual field contents from the record directly in the email body. Thus it eliminates the need for a report and the information is available just by viewing the mail not an attachment.
However the problem is that strSubject blocks the link.
 
Hi,

So if I understand correctly, you have a report which if run as-is, lists all order ids, and you want to customize it at runtime to list just the newly created order id, before emailing it?

I can't see from the syntax of the DoCmd.SendObject command how you can specify link criteria. Can you set the criteria for the Order Id column in the record source of your report to be <form name>!txtOrderId, where <form name> is the name of your form?

Keith.
 
No Keith I specifically do not wish to use a report. I can do that and the link criteria work just fine as above. I want to use the original code I posted that allows me to display the record fields directly in the body of the email, bypassing the need for a report altogether but all the variations of link criteria that I've tried fail to link the email to the record.
Barry
 
Bump

I'm still chipping away at this and I've got a couple of friends working on it, but if anyone else has any suggestions fire away!
 

Users who are viewing this thread

Back
Top Bottom