Referencing tab form in email

  • Thread starter Thread starter Tony Williams
  • Start date Start date
T

Tony Williams

I have a form on which there is a tick box which opens Outlook with data
from the form and prompts the user to amend the message before being sent.
The code is
Private Sub Loadtxt_Click()
Dim oA As Outlook.Application
Dim oM As Outlook.MailItem
Set oA = CreateObject("Outlook.Application")
Set oM = oA.CreateItem(olMailItem)
If Me!Loadtxt = True Then
oM.Subject = "Upload to Online " & Me.Docnumtxt
oM.Body = "Please upload this document to Online " & vbCrLf & "Document
Number: " & Me.Docnumtxt & vbCrLf & "Author: " & " " & Me.DocAuthortxt &
vbCrLf & "Document URL: " & " " & Me.DocURLtxt
'then you can send it
'oM.Send

' or display it for editing
oM.Display
End If
End Sub

On my form is a tab control on which there is a subform called
tblDocSubjectssubform which has a control called DocPSubjecttxt. I want to
include in the email the value of this control and have used this code &
me.tblDocSubjectssubform(DocPSubjecttxt) but it doesn't work. How can I
reference the control on the subform?

TIA
Tony Williams
 
Thanks Arvin here is the reference I have added
tblDocSubjectssubform.frmdocumentrecord.cmbPSubject
where tblDocSubjectssubform is the sub form
frmdocumentrecord is the form name
and cmbPSubject is the textbox name

BUT it doesn't work. 2 questions
1. The subform is on a tab control not directly on the form. The tabcontrol is called Page177 should this be included in the reference?
2. By adding the reference above I now get error messages that say compile error method or data member not found. If I remove the new reference works OK
 
Arvin, sorry to confuse you the tickbox control is on the tab control as is the subfor
 
You might try for your reference

[Forms]![mainformname]![subformname]![controlname]

Jim
 
Tony Williams said:
Thanks Arvin here is the reference I have added
tblDocSubjectssubform.frmdocumentrecord.cmbPSubject
where tblDocSubjectssubform is the sub form
frmdocumentrecord is the form name
and cmbPSubject is the textbox name

BUT it doesn't work. 2 questions
1. The subform is on a tab control not directly on the form. The
tabcontrol is called Page177 should this be included in the reference?

TabControls have no affect on form object references.
 
Sorry should be this

Forms![mainformname]![subformname].Form![subformcontrol]

Jim
-----Original Message-----
You might try for your reference

[Forms]![mainformname]![subformname]![controlname]

Jim


-----Original Message-----
I have a form on which there is a tick box which opens Outlook with data
from the form and prompts the user to amend the message before being sent.
The code is
Private Sub Loadtxt_Click()
Dim oA As Outlook.Application
Dim oM As Outlook.MailItem
Set oA = CreateObject("Outlook.Application")
Set oM = oA.CreateItem(olMailItem)
If Me!Loadtxt = True Then
oM.Subject = "Upload to Online " & Me.Docnumtxt
oM.Body = "Please upload this document to Online " & vbCrLf & "Document
Number: " & Me.Docnumtxt & vbCrLf & "Author: " & " " & Me.DocAuthortxt &
vbCrLf & "Document URL: " & " " & Me.DocURLtxt
'then you can send it
'oM.Send

' or display it for editing
oM.Display
End If
End Sub

On my form is a tab control on which there is a subform called
tblDocSubjectssubform which has a control called DocPSubjecttxt. I want to
include in the email the value of this control and have used this code &
me.tblDocSubjectssubform(DocPSubjecttxt) but it doesn't work. How can I
reference the control on the subform?

TIA
Tony Williams


.
.
 
Thanks Jim that partly works! The subform is in continuos forms format when the email is opened only shows the first line of the continuos form. How do I change the code to show all the values?
TIA
Tony
 
I assume you are talking about your oM.Subject and oM.body.
The fields referenced on the form is the current record on
the sub form. What is not showing up? Is you
concatenation in your oM.Body working?

Jim
-----Original Message-----
Thanks Jim that partly works! The subform is in continuos
forms format when the email is opened only shows the first
line of the continuos form. How do I change the code to
show all the values?
 
Jim, yes I am referring to the data shown in oM.Body. Here is the cod
oM.Body = "Please upload this document to Online " & vbCrLf & vbCrLf & "Document Number: " & Me.Docnumtxt & vbCrLf & "Document Name: " & Me.DocNametxt & vbCrLf & "Author: " & " " & Me.DocAuthortxt & vbCrLf & "Document URL: " & " " & Me.DocURLtxt & vbCrLf & "Primary Code: " & Forms![frmdocumentrecord]![tblDocSubjectssubform].Form![DocPSubjecttxt] & vbCrLf & "Secondary Code: " & Forms![frmdocumentrecord]![tblDocSubjectssubform].Form![cmbSSubject

The form tblDocDubjectssubform is a continuous form and can have more than one entry. What is showing in the email is the first entry and not all of them. The data for this subform is based on a seperate table than the main form frmdocumentrecor

Is that any help
Tony
 
Back
Top