Results 1 to 4 of 4
  1. #1
    Gregory23 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    28

    Exit when press cancel Form

    Hello all,



    Could you please help me how to exit the form if Cancel button is pressed in the inputbox ?

    Also is it possible to set a rule to only be able to enter to letters and 4 numbers (e.g SH1234)

    Code:
    Private Sub PrintShLabel_Click()
    
    
    DoCmd.OpenForm "ShipperLabelForm", acViewPreview, , "[UIC]=" & InputBox("Enter UIC")
    
    
    End Sub
    Click image for larger version. 

Name:	Exit form.JPG 
Views:	15 
Size:	18.6 KB 
ID:	36863

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    for a normal form, (a non-INPUT box.)

    Code:
    sub btnClose_click()
    docmd.close
    end sub
    for INPUT box, its built in.
    either use a form, or the input box, not both.

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    I think you want something like this
    Code:
    Private Sub PrintShLabel_Click()
    
    dim sUIC as string
    
    sUIC=InputBox("Enter UIC")
    
    if sUIC="" then exit sub
    
    DoCmd.OpenForm "ShipperLabelForm", acViewPreview, , sUIC     '"[UIC]=" & InputBox("Enter UIC")
    
    
    End Sub
    Cheers,
    Vlad

  4. #4
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Also is it possible to set a rule to only be able to enter to letters and 4 numbers (e.g SH1234)
    You can trap for invalid entry, including no entry, but you cannot stop the input box form from closing. You'd either have to reopen it and repeat until the entry is satisfactory, or use your own input form.
    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. Replies: 6
    Last Post: 07-07-2017, 12:23 AM
  2. Replies: 1
    Last Post: 11-17-2016, 10:55 AM
  3. Replies: 5
    Last Post: 05-27-2014, 02:44 PM
  4. Cancel an entry and exit form
    By michwh1 in forum Access
    Replies: 3
    Last Post: 03-28-2013, 03:13 PM
  5. Replies: 2
    Last Post: 12-20-2012, 03:06 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