473,698 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referencing a subform control for email

I have a form on which there is a tabcontrol and on this onr of the tabpages
is a tick box which opens Outlook with data
from the main form and prompts the user to amend the message before being
sent.
The code is
Private Sub Loadtxt_Click()
Dim oA As Outlook.Applica tion
Dim oM As Outlook.MailIte m
Set oA = CreateObject("O utlook.Applicat ion")
Set oM = oA.CreateItem(o lMailItem)
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 the tab control is a subform called
tblDocSubjectss ubform which has a control called cmbPsubject. I want to
include in the email the value of this control and have used this code
& me.tblDocSubjec tssubform(cmbPS ubject) but it doesn't work. How can I
reference the control on the subform?

TIA
Tony Williams
Nov 12 '05 #1
5 2586
Tony,
there's a really good article on www.mvps.org that you can download
that Keri Hardwick wrote that gives examples of referencing controls
on forms, subforms, subsubforms etc right here...
http://www.mvps.org/access/forms/frm0031.htm

The only problem I see with this is that you're going to have more
than one possible subject if you have a subform... are you just going
to grab the value from the first record?

HTH,
Pieter
Nov 12 '05 #2
Thanks Pieter, in answer to your question that is the problem. I've managed
to work out the syntax for the oM.Body and yhis is what I've got now
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![frmdocumentreco rd]![tblDocSubjectss ubform].Form![DocPSubjecttxt] &
vbCrLf & "Secondary Code: " &
Forms![frmdocumentreco rd]![tblDocSubjectss ubform].Form![cmbSSubject]

However because tblDocSubjectss ubform is in continuous format I'm only
picking up the first record when I need to pick all the data. Any ideas?
TIA
Tony
"Pieter Linden" <pi********@hot mail.com> wrote in message
news:bf******** *************** ***@posting.goo gle.com...
Tony,
there's a really good article on www.mvps.org that you can download
that Keri Hardwick wrote that gives examples of referencing controls
on forms, subforms, subsubforms etc right here...
http://www.mvps.org/access/forms/frm0031.htm

The only problem I see with this is that you're going to have more
than one possible subject if you have a subform... are you just going
to grab the value from the first record?

HTH,
Pieter

Nov 12 '05 #3
Kind of guessing now, but how about opening a RecordsetClone of the
subform's underlying recordsource and then looping through that and
going that way. Something like:

dim rs as dao.recordset
set rs = me!frmSub.Recor dsetClone

do until rs.eof
'do your appending here
rs.movenext
loop
Nov 12 '05 #4
Thanks for that suggestion Pieter but being a novice at coding that has me
lost! It is the "do your appending here that loses me what exactly does that
mean?
TIA
Tony
"Pieter Linden" <pi********@hot mail.com> wrote in message
news:bf******** *************** ***@posting.goo gle.com...
Kind of guessing now, but how about opening a RecordsetClone of the
subform's underlying recordsource and then looping through that and
going that way. Something like:

dim rs as dao.recordset
set rs = me!frmSub.Recor dsetClone

do until rs.eof
'do your appending here
rs.movenext
loop

Nov 12 '05 #5
"Tony Williams" <tw@tcp.invalid > wrote in message
news:bt******** **@sparta.btint ernet.com...
Thanks for that suggestion Pieter but being a novice at coding that has me
lost! It is the "do your appending here that loses me what exactly does that mean?
TIA
Tony
"Pieter Linden" <pi********@hot mail.com> wrote in message
news:bf******** *************** ***@posting.goo gle.com...
Kind of guessing now, but how about opening a RecordsetClone of the
subform's underlying recordsource and then looping through that and
going that way. Something like:

dim rs as dao.recordset
set rs = me!frmSub.Recor dsetClone

do until rs.eof
'do your appending here
rs.movenext
loop

I imagine he means adding to the string to build up the body text of the
e-mail. Although 'appending' is often used specifically when talking about
inserting new records in a table, that's not what is meant here.
I just thought I'd add a comment because I've just answered a post on
MoveFirst, which I believe you will need if you use the form's
RecordsetClone but which has not been used here.
There also seems to be a mistake with set rs = me!frmSub.Recor dsetClone
which I believe should be set rs = me!frmSub.Form. RecordsetClone
here is an example of the technique:

Private Sub cmdList_Click()

On Error GoTo Err_Handler

Dim rst As DAO.Recordset
Dim strBody As String

strBody = "Dear Santa," & vbCrLf & _
"Here is my Christmas list: " & vbCrLf

Set rst = Me!sbfSub1.Form .RecordsetClone

If rst.RecordCount > 0 Then

rst.MoveFirst

While Not rst.EOF
strBody = strBody & rst!ThingWanted & vbTab & rst!QtyRequired &
vbCrLf
rst.MoveNext
Wend

End If

MsgBox strBody, vbInformation

Exit_Handler:

If Not rst Is Nothing Then
Set rst = Nothing
End If

Exit Sub

Err_Handler:
MsgBox Err.Description , vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub

HTH
Fletcher
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8084
by: Mark B | last post by:
I have a form with a subform (normal) that itself has a subform (datasheet). I can't get a delete command button to work with the following code. It says "delete not available now". Any suggestions? '***************************************************************** Public Function DeleteRecord() Dim frm As Form, subfrm As Form
2
4764
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text box that references a field on the subform. What I'd like it to do is show the value in the field of the last record entered on the subform. But what its doing is referencing whatever record the user clicked on last before closing all the forms. Also if the user cleared the subform field, I would like the text box on the main...
3
2785
by: shumaker | last post by:
This code from the subform works for getting the value of a field of the main form named "WorkSheet": MsgBox Form_WorkSheet.Recordset.Fields("Clerk").Value Each record in the mainform datasheet called "WorkSheet" has a subform. I am trying to get the controls on the subform to reference the fields in the main form, because I think that it will resolve some of my write conflict problems by not having a recordset for the subform, and...
4
1848
by: mplogue | last post by:
I have a form (frmMain) with a subform (frmSub), each with enumerated fields of the same name (txt1, txt2, etc). I'm trying to make a function that will take the values for each field in frmMain, and put them in the same-named field in the subform. Here's the function: '--------Start Code-------- Function cmdFillSub() Dim i As Integer
2
4070
by: Axel | last post by:
Hi, a question about something that seems very simple at first glance: is it possible to reference other controls of a subform in a query window without referencing through the parent form? I want to do this as I want to use same subform on two different parent forms. Main problem is that the subform is not part of the forms collection. The only workaround I found was setting the query in code in the
6
2744
by: Mat | last post by:
Dear all, What I want to do is be able to use a string to refer to a control on a subform. IE: Forms!("Form1!form2!controlA").name or
9
7359
by: Alan | last post by:
Hmmm, I'm not too good with the syntax of referencing a subreport. I have frmInvoice which has the invoice details (e.g. ProductCode, ProductCost etc) in the subform frmInvoiceDetails. I'm trying to get a field (AccountID) to show in the parent form based on whether a particular product code (EXT) is present in the list of ProductCodes on the subform. So far I've tried: IIf(Reports!!="EXT",Null,!)
21
5095
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main form, the code errors out at the 2nd line. The error number is 13 and the description is "Type mismatch". Both controls are memo fields. I suspect that "Screen.ActiveControl.Parent" is not referencing the form as intended. Thanks for any help,...
3
3656
by: ManningFan | last post by:
Here's a fun one, mein froinds! I have a form. The form (call it MainForm) has a subform control (call it SubForm). The actual subform that SubForm displays can change based on choices made on the main form. So, SubForm can actually display SubForm1, SubForm2, SubForm3, SubForm4, etc... What I need to do is display in a messagebox the first tabbed control on the displayed SubForm.
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9027
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.