Results 1 to 4 of 4
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670

    Capture Value From Text Field

    On my form I have a textbox that is set to be format = Short Date -> From within my VBA syntax, how can I capture the value from this text box?



    Formname = frmTest
    textbox name = date1

    I have tried
    Code:
    Dim var1 String
    var1 = frmTest.date1.Text
    But this gives an error of object required

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    var1 = Forms!frmTest.date1
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Oh, and

    Dim var1 As String
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    but textbox is holding a date... I have a textbox that is set to be format = Short Date
    One could also use Me instead of the Forms reference if we're in the form module.
    How to "capture" it depends on what you want to do with it:
    - debug.print Me.date1
    - Msgbox Me.date1
    - var1 = Me.date1
    Note that .Value is the default property for a textbox, so Me.date1.Value is not required.
    Why would you set a variable to a String if you want to assign a date value to it? Shouldn't the variable be As Date, or a Variant if you expect to assign it a Null value?
    BTW, the .Text is a property that holds the visible value, which is not always the current value. For example, if the control contains Dog and you enter Cat and check the .Text value in the BeforeUpdate event, the Text property holds Cat, while the .Value property holds Dog.
    Last edited by Micron; 03-15-2017 at 06:58 PM. Reason: added info
    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. Data Capture app
    By Homegrownandy in forum Access
    Replies: 8
    Last Post: 09-24-2015, 09:02 AM
  2. How to capture totals... or sums... or something
    By Oscar.Ingalls in forum Reports
    Replies: 14
    Last Post: 03-06-2013, 10:46 PM
  3. Replies: 12
    Last Post: 06-04-2012, 10:55 AM
  4. Replies: 5
    Last Post: 01-15-2011, 01:35 AM
  5. Replies: 2
    Last Post: 05-05-2010, 02:52 PM

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