Reference another field using VBA

surkdidat

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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

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,095,840
Messages
5,446,815
Members
405,416
Latest member
galoli

This Week's Hot Topics

Top