Results 1 to 6 of 6
  1. #1
    HansBades is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2021
    Posts
    85

    empty text box


    I have an empty text box on a form not bound to anything. I have a command button next to it. When the user enters in a value and clicks the command button it will insert the value in the text box into a listbox. Before the command button executes, I have it check to see if the text box value is null. I have tried me.textboxname.value="", isnull(me.textboxname), vbNullstring, but no matter what I try it still inserts a blank value into the list box. Any idea why? How can I get the subroutine to recognize the text box is blank and not perform the routine? Thanks.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Try: in the OnClick event


    If nz(Me.textboxname,"")= "" Then 'textbox is empty

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Where are you checking?
    Sometimes you have to use the .Text value ?, not often, but sometimes.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    Join Date
    Apr 2017
    Posts
    1,792
    Text Box itself can't have Null value. In case of bound Text Box, the bound field can have Null value (when allowed). An unbound Text Box can have NullString value instead, when empty.

  5. #5
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    The question was how to stop zls or null being added into listbox row? Would have to see the code to know why. Maybe just Exit Sub is needed after the test.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    HansBades is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2021
    Posts
    85
    Thank you everyone. I got it working and found the comments very instructive. Thank you again.

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

Similar Threads

  1. Clear Record from an Empty Search Text Box
    By MeekoRayne in forum Access
    Replies: 5
    Last Post: 06-18-2020, 04:08 PM
  2. Set text box to empty
    By geotrouvetout67 in forum Programming
    Replies: 2
    Last Post: 08-30-2019, 02:13 PM
  3. Replies: 12
    Last Post: 03-01-2015, 01:36 PM
  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