Results 1 to 3 of 3
  1. #1
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194

    driving crazy, onLoad event but close form if X is true...

    Hey everyone,



    I have a form that opens another form with a listbox on it.

    What i want is that IF the listbox on the 2nd form has nothing on it, then set a bunch of values, say "no suburb found" and then close the popup form (listbox form)

    below is my code...

    Code:
    If lstSuburb.ListCount = 0 ThenMsgBox ("No Suburb Found")
    
    
    frm![txtPostcode].Value = ""
    frm![SuburbID].Value = ""
    frm![txtSuburb].SetFocus
    frm![txtSuburb].SelStart = 0
    frm![txtSuburb].SelLength = Len(frm![txtSuburb].Text)
    
    
    Exit Sub
    End If
    My current issue is that i cant get the listbox form to close!!!
    If i put docmd.close after the msgbox, then the original calling form closes.

    The same happens if i put the close command at the end near the exit sub!!!
    Ahhhh


    Such a basic idea and i cant seem to get it right!

  2. #2
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    ok ive narrowed it down a bit.

    It works IF form one is not a popup.

    as soon as form 1 becomes a popup windows as well, then docmd.close closes form1 instead of the form2 with the listbox on it..

  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,521
    I'm not clear on your specifics, but you realize you can add arguments after Close to specify the form you want closed? More info in help if not.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Dlookup driving me crazy
    By NJMike64 in forum Modules
    Replies: 3
    Last Post: 04-19-2014, 01:58 PM
  2. Replies: 6
    Last Post: 04-03-2014, 09:04 PM
  3. Too few arguments is driving me crazy....
    By Spidee in forum Access
    Replies: 3
    Last Post: 07-10-2013, 07:41 AM
  4. I know it's easy but it's driving me crazy!!!
    By pensived in forum Queries
    Replies: 1
    Last Post: 02-22-2012, 02:55 AM
  5. ShipToCode is driving me crazy
    By Accessgrasshopper in forum Access
    Replies: 7
    Last Post: 02-26-2011, 04:55 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