Reference another field using VBA

surkdidat

Well-known Member
Joined
Oct 1, 2011
Messages
579
Office Version
  1. 2016
I am trying to develop something in Access when you press a button, it brings up a msgbox (fine) and you enter a reference number.
This then launches Outlook, and in the subject field enters the number you just entered into the msgbox (again fine)

What I then need is to reference a field in that sheet to be displayed alongside the reference number.

So, for example I enter reference "1432". The Field I want is called Description (in a Table/Form called "Sheet5". It is the 3rd field in the design aspect (data imported from Excel) - how do I reference this in the VBA Code please?

Code:
Private Sub Command332_Click()
Dim oLook As Object
Dim oMail As Object
 
Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.CreateItem(0)
 pwd1 = InputBox("Please Enter the Reference Number")
With oMail
        
        .To = ""
        .CC = "aaa@aaa.com"
        .BCC = ""
        .Subject = pwd1
        .VotingOptions = "Yes,;No"
   .Display
End With
 
Set oMail = Nothing
Set oLook = Nothing
End Sub
 
Last edited:

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
If it is in the form you are clicking the button on then:

Code:
.Subject = pwd1 & " " & me.description


Should return the description value of the current record being displayed on the form.

If it is in a table then you need a way to specify which record you want to return that value for.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,941
Members
448,534
Latest member
benefuexx

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