Results 1 to 3 of 3
  1. #1
    geotrouvetout67 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    108

    Set text box to empty


    I'm using
    Code:
    Me.txtExcludeItem.Value = Null
    to clear a text box and it works fine.

    I tried this also and it does not work, wondering why?

    Code:
    Dim idVar As String
    idVar = Me.txtExcludeItem
    idVar.Value = null (also tried idVar = null)

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Because idVar holds a string which is the value in txtExcludeItem, not the control itself. String does not have properties.

    If you want an object variable then need to declare as Object and Set it. But why bother? What are you really trying to accomplish?

    Dim idVar As Object
    Set idVar = Me.txtExcludeItem
    idVar = Null

    Could do the following with string variable:
    Dim idVar As String
    idVar = Me.txtExcludeItem.Name
    Me(idVar) = Null
    Me.Controls(idVar) = Null
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    geotrouvetout67 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    108
    Ah ok.

    I don't need to do it that way, I was just playing around with code trying to understand.

    This is clearing my text box after the event happened (saving the value to a table or clearing if the value did not pass validation)

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

Similar Threads

  1. Replies: 10
    Last Post: 08-03-2016, 07:17 AM
  2. Replies: 12
    Last Post: 03-01-2015, 01:36 PM
  3. Replies: 4
    Last Post: 02-21-2014, 01:29 AM
  4. Replies: 5
    Last Post: 01-20-2014, 08:51 AM
  5. Replies: 1
    Last Post: 09-20-2012, 03:15 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