Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Angry Unanswered: I am about to Scream, these command buttons is madding

    I click on the search or exit command buttons and this is the message I am getting?? can someone help



    This error occurs when an event has failed to run because Microsoft Office Access cannot evaluate the location of the logic for the event. For example, if the OnOpen property of a form is set to =[Field], this error occurs because Access expects a macro or event name to run when the event is fired.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    What are the search and exit command buttons?, how are they defined and what is their parent object?, which are their properties?, to wich procedures are they linked and for which events?
    Have a nice day!

  3. #3
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789
    its a search button I created it with the Wizard. its in the onclick event

    Code:
    Private Sub Command354_Click()
    On Error GoTo Err_Command354_Click
    
    
        Screen.PreviousControl.SetFocus
        DoCmd****nCommand acCmdFind
    
    Exit_Command354_Click:
        Exit Sub
    
    Err_Command354_Click:
        MsgBox Err.Description
        Resume Exit_Command354_Click
        
    End Sub

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    If using a find type of command, I would set the focus to the specific control field (after the search field is updated or a button is clicked) and then issue a find on that field.

    ex:

    me.myRecIDField.setfocus
    docmd.findrecord Me!MySearchField
    me.someotherfield.setfocus

    Make sure myRecIDField field is visible and is enabled (but can be locked) (Note: You can shrink the size of the myRecIDField and/or set the focus to another field after the find command.)

    Make sure Me!MySearchField returns the myRecIDField value (ie. is a combobox or listbox) or matches the correct field you're doing the find on (ie. don't look for string value on an ID type field or vice-versa).

    You can also do it on text type search field but I found it to best work on a specific ID field. Otherwise change the above to the apropiate text field.

    Depending on the screen.previouscontrol.setfocus is not always reliable (the user could be on a different field versus the way you have it setup to work with the tab order) and doesn't always necessarily go to the correct previous control field to do the find on.
    Last edited by pkstormy; 01-28-10 at 21:56.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789
    I was wanting to create a refresh macro a Refresh macro, a Add Record, and Search Record. But the search would be on any field

  6. #6
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I use code such as:

    Screen.PreviousControl.SetFocus
    DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

    For showing the Standard MSAccess search type popup.

    To add a record, is a simple: docmd.gotorecord,,acnewrec or I'll use the wizard to quickly create a button which adds a record, deletes a record, etc....

    To refresh the form is a simple: Refresh command.

    No need to create macro's for any of these. Just put the code in on the OnClick event of a button or whichever event your calling the macro to do the same thing.
    Last edited by pkstormy; 02-02-10 at 22:08.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  7. #7
    Join Date
    Mar 2010
    Posts
    2

    Dont know Access Code for Button control

    I am having a similar problem, i have a button to add a specific record to a table from a form. I am trying to let the user seach through a drop down list, if the value is not there then there is a button to "Add", I have no idea how to get the code to add that specific data to the table. Here is some thing i have pieced together based on the code i have seen.

    Private Sub AddManufacturer_Click()
    Me.Manufacturer.Value
    DoCmd.GoToRecord , , acNewRec
    End Sub

    Some of this, like the "Value" part, was the only option that dropped down when i typed the "." i wanted to have it say "setFocus" but that wasnt a drop down option and didnt seem to work.
    Hope this makes sense, and hope someone knows how to code :/

  8. #8
    Join Date
    Mar 2010
    Posts
    2
    nevermind. figured out simpler way do achieve this

Posting Permissions

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