HELP! with email code

S

scubadiver

I posted a message yesterday about help with code for creating an email but
maybe I am posting this too soon.

At the moment I have the following:

Private Sub Tracksht_Click()

Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = QueryID & " - " & Fin_InvNo & " - " & Qry_QryType & "Query"
strToWhom = ""
strMsgBody = Qry_PropAddress1 & vbNewLine & Qry_Description

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

End Sub

I have two questions:

1) How do I compile text and fields into a string (as I have tried to do in
the "strSubject" above but doesn't seem to work). Is there something I am
missing?

2) The code above is in a button on the sub form. Some of the fields I
require are from the main form. I have tried the usual referencing but
doesn't work.

Cheers
 
S

scubadiver

I have another problem.

I have managed to sort out a basic email and the button works ok only when I
first open the database.

If I then click on the button again I get a '2957' run-time error

Daniel said:
1-
strSubject = QueryID & " - " & Fin_InvNo & " - " & Qry_QryType & "Query"
where are QueryID, Fin_InvNo, Qry_QryType defined? or are they control
within the subform?If so, I'd do
strSubject = Me.QueryID & " - " & Me.Fin_InvNo & " - " & Me.Qry_QryType &
"Query"

2- To ref forms and subforms... I use
Forms![FormName]![SubFormname]![...].Form.[ControlName]
So in your case simply use the simplest form of the above listed code
Forms![FormName].Form.[ControlName]

Daniel






scubadiver said:
I posted a message yesterday about help with code for creating an email but
maybe I am posting this too soon.

At the moment I have the following:

Private Sub Tracksht_Click()

Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String

strSubject = QueryID & " - " & Fin_InvNo & " - " & Qry_QryType & "Query"
strToWhom = ""
strMsgBody = Qry_PropAddress1 & vbNewLine & Qry_Description

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

End Sub

I have two questions:

1) How do I compile text and fields into a string (as I have tried to do in
the "strSubject" above but doesn't seem to work). Is there something I am
missing?

2) The code above is in a button on the sub form. Some of the fields I
require are from the main form. I have tried the usual referencing but
doesn't work.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top