Results 1 to 6 of 6
  1. #1
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793

    Examples of where .Value is required?

    This probably could go in a few forums but I just picked this general one. For quite some time I've wondered just how many places .Value is required in Access. Now that I've got a few in mind I thought I'd see if anyone can add to the list. Here's what I've come up with (some using the immediate window):



    1)
    If you want to know the data type that a form control contains:
    ?typename(forms!form3.[lastname].Value)
    String

    Otherwise, the control type will be returned:
    ?typename(forms!form3.[lastname])
    TextBox

    2)
    If you drill down to a form control and test/set a bunch of properties but also want to know what it contains (not its Text property):
    Code:
    With Me.myControl
      .Backcolor = vbYellow
      .ForeColor = vbBlack
      .Value = "Test"
    End With
    I suppose for #2 there might be a way around it, but the above would seem the most efficient and practical to me.

    3)
    If you need to apply query criteria to a multi value field. Since you usually would not know the mvf record index number:
    WHERE mvf_Names.Value = "Sam"

    I thought it would be required to get the value of a property but it doesn't seem to be.
    Can anyone add to the list for Access?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    You don’t need .value. It’s understood.
    ive seen it cause more problems than not. So don’t use it.

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    Well, you're wrong about that but thanks anyway.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Establishing/defining tempvars

    TempVars!tvTargetYear = Me.cboYear.Value

    You get an error if value is omitted as Access thinks you want to set the tempvar to the combo box object which is not allowed.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    Thanks Davegri. I was holding off replying to see if I got any more examples but I guess that's going to be it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    As per cj_london, .Value would be required to get the lookup value from a lookup field. I knew that was the case in queries as per #3 above, but I suppose the need can be extended to retrieving the value in a control that is being displayed from a lookup field. At least I presume he was referring to a control:
    https://www.accessforums.net/showthr...t=86171&page=2
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Modern UI Examples For Access
    By kd2017 in forum Forms
    Replies: 6
    Last Post: 03-21-2020, 06:21 PM
  2. Collection of vba examples done in word
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-29-2010, 07:16 AM
  3. Miscellaneous Examples from Sybex
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-29-2010, 06:35 AM
  4. Button Examples
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-29-2010, 06:32 AM
  5. Cool Menu Examples
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-24-2010, 12:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums