Results 1 to 6 of 6
  1. #1
    D'Anconia is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2014
    Location
    Rancho Cucamonga, CA
    Posts
    13

    Does VB lie? Help with an If/Then that doesn't work


    Hi, all!

    There's got to be something right in front of my face that I'm mising, but I don't get this. I have a form with a few drop downs. I don't want any others to be enabled until there's an entry in the first one (DDAudPer). I test this by checking the length of DDAudPer.Text in the field's OnChange procedure. Once an entry is made the others are enabled and I can make entries there. But if the first one is changed back to a blank, I want the other dropdowns to have their entries removed, and to be re-disabled. The if/then is suppposed to acheive this, but it executes the code for the length = 0 regardless of what it actually evaluates to. The code is seen in the graphic below. It shows that the debugger went to the 1st line of code as if the length<>0, while the ImmedateWindow shows it evaluating (properly) to 0.

    Any help will be appreciated!


    Click image for larger version. 

Name:	If-ThenCode.jpg 
Views:	33 
Size:	55.0 KB 
ID:	15589

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,724
    Re:Combobox ---I think this is your issue
    The Value property is set to the text in the text box portion of the control. This may or may not be the same as the setting for the Text property of the control. The current setting for the Text property is what is displayed in the text box portion of the combo box; the Value property is set to the Text property setting only after this text is saved.

    The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.

    see this for details

    Try
    Debug.print Len(DDAudPer.Value) and Debug.print Len(DDAudPer.Text)

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    Aside from dropping the .Text property, consider BeforeUpdate event instead.
    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.

  4. #4
    D'Anconia is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2014
    Location
    Rancho Cucamonga, CA
    Posts
    13
    Thanks to you both! It's quitting time now, so I'll try these suggestioins tomorrow and let you know if they resolved the problem.

    I really appreciate your speedy responses!

  5. #5
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    (debug T, to check the value if you need to)
    T= me.DDAudPer
    If IsNull(T) then
    ....
    else
    ....
    end if

  6. #6
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    You have your code in the wrong event. The On Change fires as soon as you make ANY change in the field, e.g. deleting a character.

    Try putting your code in the After Update or the On Exit event instead.

    HTH

    John

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

Similar Threads

  1. Just doesn't seem to work!
    By txmmoore in forum Reports
    Replies: 9
    Last Post: 01-16-2014, 11:39 AM
  2. My query code doesn't work
    By blacksaibot in forum Programming
    Replies: 2
    Last Post: 03-08-2012, 02:59 PM
  3. App doesn't work with runtime
    By bubba55 in forum Access
    Replies: 0
    Last Post: 09-21-2011, 08:33 AM
  4. Can Grow doesn't work
    By gg80 in forum Reports
    Replies: 6
    Last Post: 05-13-2011, 07:14 PM
  5. Query doesn't work the day after
    By sithis876 in forum Queries
    Replies: 1
    Last Post: 07-13-2010, 07: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