Reference unbound Text Box from one Form to Another (2 Viewers)

Dundee

New member
Local time
Today, 16:07
Joined
Mar 8, 2020
Messages
14
Hi,

i'm kind of new to this forums. i am trying to figure this code. how can i reference unbound txtbox from one form to another.
maybe you can help me out.

Code:
Private Sub EmailDistOut_Click()
   DoCmd.OpenForm "SubmittalEmailOUT"
   Dim stfilter As String
   stfilter = stfilter & "([Forms!SubmittalEditRecord!SubmittalRefNo] LIKE  '*" & Forms!SubmitalEmailRecord!Me.txtSblEmail & "*')"
   Forms("SubmittalEditRecord").Form.Filter = stfilter
   Forms("SubmittalEmailOut").Form.FilterOn = True
 
End Sub
 
Last edited by a moderator:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:07
Joined
Jul 9, 2003
Messages
16,332
I don't use this particular method. I will post some links explaining a method I prefer.

However I note that this line:- Forms("SubmittalEmailOut").Form.FilterOn = True

And This line:-
Forms("SubmittalEditRecord").Form.Filter = stfilter

They are referring to different forms, shouldn't they refer to the same form?
 

vba_php

Forum Troll
Local time
Today, 08:07
Joined
Oct 6, 2019
Messages
2,880
Have a look here http://access.mvps.org/access/forms/frm0031.htm Bookmark it!
It shows you the format for all possibilities of references to form objects both with forms and not on forms.
that's quite a lot to swallow, or digest, Minty. =)

Dundee, you say this:
how can i reference unbound txtbox from one form to another
but in your code you are attempting to filter an entire form and it's records. that's contradicting itself. if you want to THROW the value of one text box on one form that is already open (form 1), to a textbox on another form that is ALSO already open (form 2), you do it like this:
Code:
forms!FORM2_NAME_HERE!textbox_name_here = forms!FORM1_NAME_HERE!textbox_name_here
 

Dundee

New member
Local time
Today, 16:07
Joined
Mar 8, 2020
Messages
14
I don't use this particular method. I will post some links explaining a method I prefer.

However I note that this line:- Forms("SubmittalEmailOut").Form.FilterOn = True

And This line:-
Forms("SubmittalEditRecord").Form.Filter = stfilter

They are referring to different forms, shouldn't they refer to the same form?
Hi, Mr. Gizmo,

yes, they are referring to a different form forms SubmittalEmailOut and SubmittalEditRecord. basically i just wanted to put a button
on SubmittalEditRecord form and filter SubmittalEmailOut form. anyway thanks for your reply. nice to meet you Mr. Gizmo.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:07
Joined
Jul 9, 2003
Messages
16,332
yes, they are referring to a different form forms

Why are they referring to different forms? You are setting the filter in one form, and then switching the filter on in another form. That doesn't seem to make sense to me. Could you explain it better...
 

jdraw

Super Moderator
Staff member
Local time
Today, 09:07
Joined
Jan 23, 2006
Messages
15,394
I agree with Tony --could you please describe WHAT you are trying to achieve in simple terms rather than HOW you have done/are trying to do "something". We need to understand the "something".
 

Dundee

New member
Local time
Today, 16:07
Joined
Mar 8, 2020
Messages
14
Why are they referring to different forms? You are setting the filter in one form, and then switching the filter on in another form. That doesn't seem to make sense to me. Could you explain it better...
Hi Mr. Gizmo,

Actually what i'm trying to achieve is like this. kindly refer to attached file and screen shot.
i want copy data from one form to another , so i can send it through email. but i think my approach is wrong not filter i guess.
as you can see on a the screen shot. copy the current data to my email form.
 

Attachments

  • Screen Shot.PNG
    Screen Shot.PNG
    96.6 KB · Views: 124

Dundee

New member
Local time
Today, 16:07
Joined
Mar 8, 2020
Messages
14
Hi Mr. Gizmo,

Actually what i'm trying to achieve is like this. kindly refer to attached file and screen shot.
i want copy data from one form to another , so i can send it through email. but i think my approach is wrong not filter i guess.
as you can see on a the screen shot. copy the current data to my email form.
This is my what i have on my email form

Private Sub SendEmailBtn_Click()

Dim mess_body As String
Dim add As String
Dim appOutLook As Object
Dim MailOutLook As Object

Const olMailItem As Long = 0
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

With MailOutLook

'Add the To recipient(s) to the message.
.to = Me.address

' Add the CC recipient(s) to the message.
.CC = Me.CCBox

' Add the BCC recipient(s) to the message.
.Bcc = Me.Bcc

' Set the Subject, Body, and Importance of the message.
.Subject = Me.MsgSubject - ' some Code to Collect the current description and submittal Ref number of submittaleditRecord '
.Body = Me.MsgBody

'End If


End If
Next
.Send

End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing


End Sub
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:07
Joined
Jul 9, 2003
Messages
16,332
As an alternative to OpenAgs I've done a quick Video demonstration using the method that I referred to earlier...

Open One form From Another And Pass Info - Nifty Access

 

Dundee

New member
Local time
Today, 16:07
Joined
Mar 8, 2020
Messages
14
As an alternative to OpenAgs I've done a quick Video demonstration using the method that I referred to earlier...

Open One form From Another And Pass Info - Nifty Access

wow! you guys are great, i relay appreciate the help.. :D
 

Dundee

New member
Local time
Today, 16:07
Joined
Mar 8, 2020
Messages
14
that's quite a lot to swallow, or digest, Minty. =)

Dundee, you say this:but in your code you are attempting to filter an entire form and it's records. that's contradicting itself. if you want to THROW the value of one text box on one form that is already open (form 1), to a textbox on another form that is ALSO already open (form 2), you do it like this:
Code:
forms!FORM2_NAME_HERE!textbox_name_here = forms!FORM1_NAME_HERE!textbox_name_here
wow ! thanks a lot..
 

Dundee

New member
Local time
Today, 16:07
Joined
Mar 8, 2020
Messages
14
i hope thats not sarcastic! 😀 did it solve the issue?
yeah .. it really did now its working .. earlier i was doing filtering approach to match the record in another form ..ges its totally wrong. thanks again Mr. VBA
 

Minty

AWF VIP
Local time
Today, 14:07
Joined
Jul 26, 2013
Messages
10,372
Glad you have it sorted.

I would study the links from both Uncle and myself.

OpenArgs is a really nice simple way to control how forms behave when they are opened from different sources.
By hard coding the email form to those values you can't easily reuse it in another part of your application.
 

Dundee

New member
Local time
Today, 16:07
Joined
Mar 8, 2020
Messages
14
yeah .. it really did now its working .. earlier i was doing filtering approach to match the record in another form ..ges its totally wrong. thanks again Mr. VBA
I just want to thank you guys again.. it really work.. see attach screen shoot..

Private Sub AttachedSubject_Click()
Dim StrFrmName As String
StrFrmName = "SubmittalEditRecord"
With Forms(StrFrmName)
Me.MsgSubject = "Contractor Ref: " & .SubmittalRefNo & " Client Consultant Ref: " & .ReplyRefNo & " Approval Status: " & .ApprovalCategory & " - " & .Description
Me.MsgBody = "File Directory: " & .FileLocation2
End With
End Sub
 

Attachments

  • Screen Shot.PNG
    Screen Shot.PNG
    145.9 KB · Views: 108

Dundee

New member
Local time
Today, 16:07
Joined
Mar 8, 2020
Messages
14
I just want to thank you guys again.. it really work.. see attach screen shoot..

Private Sub AttachedSubject_Click()
Dim StrFrmName As String
StrFrmName = "SubmittalEditRecord"
With Forms(StrFrmName)
Me.MsgSubject = "Contractor Ref: " & .SubmittalRefNo & " Client Consultant Ref: " & .ReplyRefNo & " Approval Status: " & .ApprovalCategory & " - " & .Description
Me.MsgBody = "File Directory: " & .FileLocation2
End With
End Sub

Email Code Works also

Private Sub SendEmailBtn_Click()

Dim sTo As String
Dim sCC As String
Dim sBCC As String
Dim sSub As String
Dim sBody As String
Dim strCC As String
Dim OutApp As Object
Dim OutMail As Object
Dim varPress As Variant

strMess = "You are about to send an email message to the current user." & vbCrLf & vbCrLf
strMess = strMess & "Do you wish to continue?"

strStyle = vbYesNo
strTitle = "Send Notificaiton"

varPress = MsgBox(strMess, strStyle, strTitle)
If varPress = vbYes Then
' Get the email address from the current form control
sTo = Me.ToEmails
sCC = Me.CCBox
sBCC = Me.Bcc
' Set the subject
sSub = Me.MsgSubject

' Build the body of the email
sBody = Me.MsgBody & vbCrLf & vbCrLf
sBody = sBody & "Dear Sir," & vbCrLf & vbCrLf
sBody = sBody & "The following document has been replied by our client consultant. Approval Status as per attached subject above." & vbCrLf & vbCrLf
sBody = sBody & "best regards," & vbCrLf & vbCrLf
sBody = sBody & "DCC Team"

' Create the email
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail
.to = sTo
.CC = sCC
.Bcc = sBCC
.Subject = sSub
.Body = sBody
.Display
'.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing

Exit_SendEmailBtn_Click:
Exit Sub

Err_SendEmailBtn_Click:
MsgBox Err.Description
Resume Exit_SendEmailBtn_Click

End If

End Sub
 

Users who are viewing this thread

Top Bottom