By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,838 Members | 2,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,838 IT Pros & Developers. It's quick & easy.

Reference a Text Box from another Form displayed on a Tab Control

P: n/a
Hi, I'm having a bit of trouble editing an old database that was
created quite a while ago by someone else.

There is a form that lets the user select a member of staff and show
details about the training they have had.

What im trying to add to this is an email button which emails the
person selected - i've managed to be able to do grab the email and
create a new email message with the coresponding email adress.

What i want to do now is put in the body of the email details stored in
text boxes.

I'm having trouble referencing these text boxes as they are stored on
another form which is displayed on this form using a Tab Control.

The tab I want to grab details from is called tabTraining.This gets its
data from form called trainingPlan. And there are various text boxes.

How do i reference these boxes to add the text stored in them to a
variable called sAddedtext.

Is it something like sAddedtext = tabTraining.trainingPlan.textbox.text

Not sure if i'm on the right lines.

Please help :)

Nov 13 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
<si************@gmail.com> wrote in message
news:11********************@g47g2000cwa.googlegrou ps.com...
Hi, I'm having a bit of trouble editing an old database that was
created quite a while ago by someone else.

There is a form that lets the user select a member of staff and show
details about the training they have had.

What im trying to add to this is an email button which emails the
person selected - i've managed to be able to do grab the email and
create a new email message with the coresponding email adress.

What i want to do now is put in the body of the email details stored in
text boxes.

I'm having trouble referencing these text boxes as they are stored on
another form which is displayed on this form using a Tab Control.

The tab I want to grab details from is called tabTraining.This gets its
data from form called trainingPlan. And there are various text boxes.

How do i reference these boxes to add the text stored in them to a
variable called sAddedtext.

Is it something like sAddedtext = tabTraining.trainingPlan.textbox.text

Not sure if i'm on the right lines.

Please help :)

Whether any particular control is placed on a tab control actually makes no
difference to how you reference it.
So even if txtBox1 was on one part of the form and txtBox2 was on the tab
control, they would be referenced in exactly the same way:
Value1=Me.txtBox1
Value2=Me.txtBox2

This is the part which may be troublesome:
[[...as they are stored on another form which is displayed on this form
using a Tab Control....]]
It sounds like you are using a subform. Here, the complexity is that even
though you may have designed two forms: Form1 (used as the main form) and
Form2 (used as the subform), once Form2 is placed on Form1 it is being used
as a subform *control* and the name of the control should show this. Eg the
name of the control would be sbfMySub even though its SourceObject (the
actual form it uses) is Form1.
When referering to these textboxes you would write:
Forms!Form1.sbfMySub.Form.txtSomeTextBox
or, from within Form1
Me.sbfMySub.Form.txtSomeTextBox


Nov 13 '05 #2

P: n/a
Hi thanks for that I've used

Me.trainingplan.Form.Course

This works fine to get the info for one text box however the form is a
Continuous Form. So i need to be able to extract the text from all the
textboxes of the same name. Is this possible?

Sorry for all the questions . Im a newbie to this.

Cheers

Nov 13 '05 #3

P: n/a
<si************@gmail.com> wrote in message
news:11********************@g47g2000cwa.googlegrou ps.com...
Hi thanks for that I've used

Me.trainingplan.Form.Course

This works fine to get the info for one text box however the form is a
Continuous Form. So i need to be able to extract the text from all the
textboxes of the same name. Is this possible?

Sorry for all the questions . Im a newbie to this.

Cheers

I asssume, then, this subform is bound to a datasource that has a field
named "Course" - and this is what we'll look at. The name of the textbox
control which displays this information is not relevant. Here we can use
the RecordsetClone to loop through all the records on the subform:

With Me.trainingplan.Form.RecordsetClone
.MoveFirst
While Not .EOF
MsgBox Nz(.Fields("Course"))
.MoveNext
Wend
End With
Nov 13 '05 #4

P: n/a
Thats pretty darn cool! Thanks

So if i want to add all this textbox stuff then id do something like..

sAddedtext = sAddedtext & "&Body=" & Nz(.Fields("Course"))

But that only adds the last box. i need it to contatenate it or
something?

Cheers in advance.

Nov 13 '05 #5

P: n/a
<si************@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Thats pretty darn cool! Thanks

So if i want to add all this textbox stuff then id do something like..

sAddedtext = sAddedtext & "&Body=" & Nz(.Fields("Course"))

But that only adds the last box. i need it to contatenate it or
something?

Cheers in advance.

You're still using the loop, right? So I guess you're building up some form
of course list (for the body of an e-mail? guessing by the body). Anyway, I
don't understand [[...only adds the last box...]] unless you have removed
the loop. Don't you need something like:

Dim strList As String

With Me.trainingplan.Form.RecordsetClone
.MoveFirst
While Not .EOF
strList = strList & "<BR>" & Nz(.fields("Course"))
.MoveNext
Wend
End With

Debug.Print strList
Nov 13 '05 #6

P: n/a
Thats the ticket!

Thanks for that!

I may post back here for more help on the matter if it arises. Thanks
for your time!!

You are much more with it than the other Brian Wilson of Beach Boys
fame!

Cheers again!

Nov 13 '05 #7

P: n/a
Ok this is what i've got..
Dim strList As String
With Me.trainingplan.Form.RecordsetClone
.MoveFirst
While Not .EOF
strList = strList & Chr$(13) & Nz(.Fields("Course"))
.MoveNext
Wend
End With
sAddedtext = sAddedtext & "&Body=" & strList

Debug.Print strList
MsgBox sAddedtext
The <BR> didnt work. Chr$(13) works to get a carrige return in the
message box but when this is added to the email body i just get one
long line of text- i've got Outlook set to text only.

Eventually I want to have a table of rows & colmns displayed in the
body of the text.

Sorry for being so dumb. Just getting started with all this.

Cheers

Nov 13 '05 #8

P: n/a

<si************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Ok this is what i've got..
Dim strList As String
With Me.trainingplan.Form.RecordsetClone
.MoveFirst
While Not .EOF
strList = strList & Chr$(13) & Nz(.Fields("Course"))
.MoveNext
Wend
End With
sAddedtext = sAddedtext & "&Body=" & strList

Debug.Print strList
MsgBox sAddedtext
The <BR> didnt work. Chr$(13) works to get a carrige return in the
message box but when this is added to the email body i just get one
long line of text- i've got Outlook set to text only.

Eventually I want to have a table of rows & colmns displayed in the
body of the text.

Sorry for being so dumb. Just getting started with all this.

Cheers

It's not dumb to ask - that's what the group is here for. Anyway, some of
us prefer answering questions here than getting on with our real projects!
Try the built-in vbCrLf which is a carriage return and line-feed character -
the same as Chr$(13) & Chr$(10) I think. Of course, rows and columns can be
more nicely formatted if you have an html body, but I understand why you
might want to produce a text-only body.

Nov 13 '05 #9

P: n/a
<si************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Ok this is what i've got..
Dim strList As String
With Me.trainingplan.Form.RecordsetClone
.MoveFirst
While Not .EOF
strList = strList & Chr$(13) & Nz(.Fields("Course"))
.MoveNext
Wend
End With
sAddedtext = sAddedtext & "&Body=" & strList

Debug.Print strList
MsgBox sAddedtext
The <BR> didnt work. Chr$(13) works to get a carrige return in the
message box but when this is added to the email body i just get one
long line of text- i've got Outlook set to text only.

Eventually I want to have a table of rows & colmns displayed in the
body of the text.

Sorry for being so dumb. Just getting started with all this.

Cheers

<possible re-post>

It's not dumb to ask - that's what the group is here for. Anyway, some of
us prefer answering questions here than getting on with our real projects!
Try the built-in vbCrLf which is a carriage return and line-feed character -
the same as Chr$(13) & Chr$(10) I think. Of course, rows and columns can be
more nicely formatted if you have an html body, but I understand why you
might want to produce a text-only body.

Nov 13 '05 #10

P: n/a
Hi ya,

He he! Thanks for helping mate.

Unfortunatly I've already tried vbCrLf and it didnt seem to work. I
still get one line of text. When i show the string in a Msgbox i get
carrige returns but not in the email.

I've even tried setting outlook to create html emails and tried <BR>
but to no avail.

Hmmm! Strange

Thanks for your help

Nov 13 '05 #11

P: n/a
Hi I'm still having this issue can anyone help?

Nov 13 '05 #12

P: n/a
On 10 Oct 2005 01:44:34 -0700, si************@gmail.com wrote:
Hi I'm still having this issue can anyone help?


Post your new code. It is likely there is an error, because vbcrlf
should work.

mike

Nov 13 '05 #13

P: n/a
Dim strList As String
With Me.trainingplan.Form.RecordsetClone
.MoveFirst
While Not .EOF
strList = strList & vbCrLf & Nz(.Fields("Course"))
.MoveNext
Wend
End With

sAddedtext = sAddedtext & "&Subject=" & "Training Plan"
sAddedtext = sAddedtext & "&Body=" & strList
Debug.Print strList
stext = "mailto:" & stext
stext = "mailto:" & stext
If Len(sAddedtext) <> 0 Then
Mid$(sAddedtext, 1, 1) = "?"
End If

stext = stext & sAddedtext
MsgBox stext ' This outputs it with seperate rows in the message
box

' launch default e-mail program
If Len(stext) Then
Call rubbish(hwnd, "open", stext, vbNullString,
vbNullString, 1)
End If

Nov 13 '05 #14

P: n/a
On 10 Oct 2005 08:44:47 -0700, si************@gmail.com wrote:
Dim strList As String
With Me.trainingplan.Form.RecordsetClone
.MoveFirst
While Not .EOF
strList = strList & vbCrLf & Nz(.Fields("Course"))
.MoveNext
Wend
End With

sAddedtext = sAddedtext & "&Subject=" & "Training Plan"
sAddedtext = sAddedtext & "&Body=" & strList
Debug.Print strList
stext = "mailto:" & stext
stext = "mailto:" & stext
If Len(sAddedtext) <> 0 Then
Mid$(sAddedtext, 1, 1) = "?"
End If

stext = stext & sAddedtext
MsgBox stext ' This outputs it with seperate rows in the message
box

' launch default e-mail program
If Len(stext) Then
Call rubbish(hwnd, "open", stext, vbNullString,
vbNullString, 1)
End If


It looks like your rubbish program is not capable of understanding the
vbcrlf as vbcrlf characters. Better look into the documentation and
see what it does with the stest variable. If it "strips" all c/r's
out, then you putting them in isn't going to do much.

mike

Nov 13 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.