Results 1 to 14 of 14

Thread: clear button

  1. #1
    Join Date
    Apr 2007
    Posts
    81

    Unanswered: clear button

    HI all

    When I click on the clear button I get error msg.
    The clear button erases a text in country search box.

    I use this code by Expression builder
    =ClearFilterElement([SrchBox1])

    thanks
    Attached Thumbnails Attached Thumbnails Clear.bmp  

  2. #2
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    Try this:

    Me.[FieldName] = ""

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    =ClearFilterElement([SrchBox1]) must be placed directly into the OnClick properties box for the Command Button.

    If it is, then you do not have the ClearFilterElement Function in your SubForm code module.

    You can only use the above method directly into a control Property with either a Macro or a Function and that Function must be either local to the Form where the control is located or Declared as Public from a Database Code Module.

    Locate the Function ClearFilterElement and copy/paste it into your SubForms' code module.

    =ClearFilterElement([SrchBox1]) will work fine then.

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  4. #4
    Join Date
    Apr 2007
    Posts
    81
    HI

    CyberLynx
    I see this function in your sample but I do not know how I make it.

    please make it for me in my sample attch in this reply.

    thanks
    [Attachment removed by GeorgeV. Reason: Not doing the work for you!]
    Last edited by gvee; 11-27-07 at 05:35.

  5. #5
    Join Date
    Apr 2007
    Posts
    81
    HI CyberLynx

    =ClearFilterElement([SrchBox1])

    I used the code in Command Button OnClick properties.

    where is exactly paste the code on SubForm code module.

  6. #6
    Join Date
    Nov 2003
    Posts
    1,487
    Paste it at the very bottom of the module. You will need to open up the SubForm code module to do this.

    To open the SubForm code module:

    - from the database window, open the SubForm in Design View,
    - then in the Access View menu, select the Code menu item.
    - The SubForm code module will open up within the VBA IDE.
    - If there is code already within this module then go to the very bottom where there is no code. Hit the Enter key a couple times if you have to. Paste the function there.
    - Select the Save button in the IDE tool bar (button with a Floppy Disk on it).
    - Close the VBA IDE application.
    - Run your Main Form.


    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  7. #7
    Join Date
    Apr 2007
    Posts
    81
    I make like this code but still!

    Private Sub Command36_Click()
    =ClearFilterElement([SrchBox1])
    End Sub

    if you can send image

  8. #8
    Join Date
    Nov 2003
    Posts
    1,487
    Rather than placing the function call into the Properties Window for the Command Button OnClick event, you placed it directly into the code module for the OnClick event (see attached Image file).

    If you place it directly into the code module then you need to remove the equal symbol and place the Call statement in front as shown below:

    Call ClearFilterElement([SrchBox1])

    or you can foreget about the Call statement but you must remove the brackets, like so:

    ClearFilterElement [SrchBox1]


    If the call to this or any other function is to be made from the Properties Window then that function name must be preceded by the equal sign, like so:

    =ClearFilterElement([SrchBox1])

    Just consider the equal sign as being the call statment if you like.

    I hope you actually copied and pasted the actual Function Code into your SubForms' code module.

    .
    Attached Thumbnails Attached Thumbnails Image1.png  
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  9. #9
    Join Date
    Apr 2007
    Posts
    81
    Hi

    I do as the picture you sent, When click on the clear button I get error msg
    the image in this reply.
    Attached Thumbnails Attached Thumbnails Clear.gif.bmp  

  10. #10
    Join Date
    Nov 2003
    Posts
    1,487
    The most probable reason as to why you are getting this Error is because you do not have the function copied to your SubForm code module. You need to do this.

    Take a closer look at the sample files I posted earlier (I will attach again here). Open the code module for your Form named AreaCodFrm. At the very end of this module is the Function code:

    Code:
    Private Function ClearFilterElement(Ctrl As Control)
       'Clear the Filter Element TextBox will Null.
       Ctrl = Null
       'SetFocus onto the Control just cleared.
       Ctrl.SetFocus
    End Function
    This function must reside within the code module for the AreaCodFrm you are using now.

    The Function is designed for use against mulitple controls. From your previous posts in this thread, you obviously don't want that. You only want to clear one TextBox. Realistically then, you don't need this function. You can place the same code (slightly modified) into your Command Buttons' (Command36) OnClick event like this:

    Code:
    Private Sub Command36_Click()
       'Clear the Filter Element TextBox will Null.
       Me.SrchBox1 = Null
       'SetFocus onto the Control just cleared.
       Me.SrchBox1.SetFocus
    End Sub
    This will do exactly the same thing as the ClearFilterElement Function but ONLY for the SrchBox1 TextBox Control.

    .
    Attached Files Attached Files
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  11. #11
    Join Date
    Apr 2007
    Posts
    81
    HI
    I can not make
    Private Function ClearFilterElement

    see the image.

    thanks
    Attached Thumbnails Attached Thumbnails Clear.bmp   Clear2.bmp  

  12. #12
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    On click - build event.
    In the event itself, call the function.
    George
    Home | Blog

  13. #13
    Join Date
    Nov 2003
    Posts
    1,487
    Again....as in earlier posts...you do not have the function ClearFilterElement in your AreaCodFrm Forms code module. Your attached mega image shows that.

    This function must reside within the code module for things to work IF the function call =ClearFilterElement() is placed directly into the OnClick properties box.

    In my last post...I attached your sample DB and you can clearly see that the function is in there. You don't have to make the function...I had already done that for you and that is the last thing I'm going to do. All you need to do is copy and Paste it into you code module just as I shown within the image file I have attached to this post. You do know how to copy & paste right? If not then I can explain to you how to do it.

    I am not going to do this for you. This is a hurdle you will need to overcome yourself. Hitting the books (reading) is strongly recommended here at this point. I apologize, but I just can't explain it any better.

    .
    Attached Thumbnails Attached Thumbnails Image2.png  
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  14. #14
    Join Date
    Apr 2007
    Posts
    81
    Hi CyberLynx


    I am very sorry for misunderstand and confuse about the function ClearFilterElement,

    Thank you so much for your help, I greatly appreciate, you have always respond and been very helpful.

Posting Permissions

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