Reference another field using VBA

surkdidat

Active Member
Joined
Oct 1, 2011
Messages
359
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:

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

stumac

Active Member
Joined
Jul 16, 2010
Messages
471
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:

Watch MrExcel Video

Forum statistics

Threads
1,100,095
Messages
5,472,462
Members
406,818
Latest member
NeoTrader

This Week's Hot Topics

Top