Results 1 to 2 of 2

Thread: Reference another field using VBA
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Oct 2011
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)

    Default Reference another field using VBA

    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?

    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 = ""
            .BCC = ""
            .Subject = pwd1
            .VotingOptions = "Yes,;No"
    End With
    Set oMail = Nothing
    Set oLook = Nothing
    End Sub
    Last edited by surkdidat; Jun 12th, 2019 at 10:39 AM.

  2. #2
    Board Regular
    Join Date
    Jul 2010
    Post Thanks / Like
    2 Post(s)
    0 Thread(s)

    Default Re: Reference another field using VBA

    If it is in the form you are clicking the button on then:

    .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 by stumac; Jun 12th, 2019 at 11:06 AM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts