Consulting

Results 1 to 5 of 5

Thread: Exit sub issues

  1. #1

    Question Exit sub issues

    I have this formula but cannot make the exit sub function work when I insert this command. I want the box to close when okay is selected to eliminate the possibility of duplicate entries

    HELP


    [VBA]Private Sub Okay_Click()
    Columns("A:E").Select
    ActiveSheet.Unprotect
    Range("B2").Select
    Do
    If IsEmpty(ActiveCell) = False Then
    ActiveCell.Offset(1, 0).Select
    End If

    Loop Until IsEmpty(ActiveCell) = True
    ActiveCell.Value = Ministry.Value
    ActiveCell.Offset(0, 1) = FiscalYear.Value
    ActiveCell.Offset(0, 2) = TypeOfDoc.Value
    ActiveCell.Offset(0, 3) = DocPpdBy.Value
    ActiveCell.Offset(0, 4) = EnteredBy.Value
    Columns("A:E").Select
    ActiveSheet.Unprotect
    ActiveSheet.Calculate


    With Worksheets("entry")
    If Not .AutoFilterMode Then
    .Range("A1").AutoFilter
    End If
    .EnableAutoFilter = True
    .Protect , _
    Contents:=True, UserInterfaceOnly:=True

    End With

    'ActiveSheet.Protect
    End Sub[/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What box are you referring to? Is it a userform or something else?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    Welcome to the forum- it's always good to see new members.

    If your click event refers to a UserForm, then you can close the forum using this code:
    [vba]Me.Unload[/vba]
    Me refers to the current, active form- the form that the code is behind. Unload closes the UserForm and clears the memory.

    If this isn't the answer you're looking for, then please provide some more detail.

    Also, when you post code please wrap your code in VBA tags (click the green VBA button). This will format the code according to VBIDE and make it easier to read.

    If your issue is resolved, please mark the thread as solved by clicking on Thread Tools at the top of this window, and select Mark As Solved- it will help keep the forum clean.

    HTH
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  4. #4

    exit sub

    I have tried the Me.Upload and it errors out. The macro allows the user to enter in data via a form with drop down choices. Once completed they can select the okay button on the user form to enter the data. At this point I would like the box/user form to close.

    Please advise

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    unload me

    just above End Sub
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •