Global Variable Question

Huey462

Board Regular
Joined
Jul 25, 2011
Messages
147
I have a program that pulls the information and displays it in an invisible text box. VBA code then assigns the textbox value to the global variable.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
<o:p></o:p>

Code:
[COLOR=black][FONT=Times New Roman]QEmailTo = Me.EmailToCheat.Value[/FONT][/COLOR]
<o:p></o:p>
<o:p></o:p>

While this works, I wonder if it is possible to use VBA to assign the value straight out of the table rather then use the text boxes.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Possibly just use DLookup. Check out the help file but I *think* it goes either:

Without any criteria:
=DLookup("[Field1]","[Table1]")

With a numeric criterion:
=DLookup("[Field1]","[Table1]","[ID]=1")

With a text criterion:
=DLookup("[Field1]","[Table1]","[ID]='ABC-101'")

With a Date criterion:
=DLookup("[Field1]","[Table1]","[TranDate]=#1/1/2012#")
 
Upvote 0
Works great. As always, thank you for the quick response.

Code:
Private Sub btnEmail_Click()
    'Declares Variables
    Dim txtEmailAddy As String
    Dim txtEmailBody As String
    'Assigns Values
    txtEmailAddy = DLookup("EmailTo", "ExportInformation")
    txtEmailBody = DLookup("[EmailBody]", "[ExportInformation]")
    'Puts values on screen
    Me.txtbxEmailAddy = txtEmailAddy
    Me.txtbxEmailBody = txtEmailBody
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top