Results 1 to 12 of 12

Thread: on click error

  1. #1
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    178

    Question Unanswered: on click error

    i have an On Click event on a button on a subform. it doesn't matter what code is in the event because it doesn't seem to even get to read the code. I get the following error:

    The expression On Click you entered as the event property setting produced the following error: A problem occurred while Microsoft Access was communicating with the OLE server or ActiveX Control.

    * The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure].
    * There may have been an error evaluating the function, event, or macro.


    what could be the problem?
    thanks again in advance

  2. #2
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Re: on click error

    Originally posted by actionant
    i have an On Click event on a button on a subform. it doesn't matter what code is in the event because it doesn't seem to even get to read the code. I get the following error:

    The expression On Click you entered as the event property setting produced the following error: A problem occurred while Microsoft Access was communicating with the OLE server or ActiveX Control.

    * The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure].
    * There may have been an error evaluating the function, event, or macro.


    what could be the problem?
    thanks again in advance
    ActionAnt,

    Why don't you post the code for your button's OnClick event, that might help to better assess your problem. And then explain just what you wish the button to do.
    Bud

  3. #3
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    178
    I can change the code as i want. it doesn't make a difference. even if i just put a msgbox in the code. the code isn't the problem because it doesn't get read.
    All i want the button to do is open a form.
    i get the same error if i use the wizard to create the button

  4. #4
    Join Date
    Jun 2003
    Location
    Belgium
    Posts
    133
    ActionAnt,

    You probably have an ActiveX in the form for which you are not registered.
    If so, register the ActiveX before using it.

  5. #5
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    178
    i don't remember adding an activeX. is this something that would have been done automatically? if so, how do i find it what would the path be to register it? I know nothing about ActiveX.

  6. #6
    Join Date
    Jun 2003
    Location
    Belgium
    Posts
    133
    An ActiveX object is visible on the design view of your form.

    But these things are not added automatically. If you did not add them, it will not be the cause of your problem.
    Unless you received the database from someone else....

    To find the cause of your problem : did you try to compile the code?
    Remember that all code is autmatically compiled when loading the form. You should check on compile errors before opening it.
    If you never heard about compiling, you find the compile command in the VB window (first command in menu "Debug")
    Compiling your code will guide you automatically to the error in your code.

  7. #7
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Does it occur on yur machine or on another machine?
    to register an ActiveX use Regsvr32 PathOfTheObject
    Example
    Regsvr32 c:\WinNt\System32\MSGrid.ocx

  8. #8
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    178
    Originally posted by Herman
    An ActiveX object is visible on the design view of your form.

    But these things are not added automatically. If you did not add them, it will not be the cause of your problem.
    Unless you received the database from someone else....

    To find the cause of your problem : did you try to compile the code?
    Remember that all code is autmatically compiled when loading the form. You should check on compile errors before opening it.
    If you never heard about compiling, you find the compile command in the VB window (first command in menu "Debug")
    Compiling your code will guide you automatically to the error in your code.
    thanks i've compiled the code. there aren't any errors. I created the form myself and didn't add any activeX. I've also only been working on one PC. i still get the same error. whats the next step?

  9. #9
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    178
    Originally posted by hammbakka
    Does it occur on yur machine or on another machine?
    to register an ActiveX use Regsvr32 PathOfTheObject
    Example
    Regsvr32 c:\WinNt\System32\MSGrid.ocx
    i haven't added any activeX controls to my form. i've also only been working on the same PC. any suggestions?

  10. #10
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    178
    i can get it to work if i use a macro. the only problem then is that i have 3 buttons that will use the same macro to open the same form. how do i check which button was clicked?
    i've tried the following as a condition in the macro:

    Source = command17

    and then just display a msgbox
    but this doesn't work

  11. #11
    Join Date
    Jun 2003
    Location
    Belgium
    Posts
    133
    dump the macro's! Use code instead.

    Although I can't see the meaning on using 3 buttons to do exactly the same, here's a solution:

    On button A, set this code in the event OnClick :
    DoCmd.OpenForm "frmMyForm", , , , , , "A"
    Button B, use this code :
    DoCmd.OpenForm "frmMyForm", , , , , , "B"
    Button C, use this code :
    DoCmd.OpenForm "frmMyForm", , , , , , "C"

    In the OnLoad event of form "frmMyForm", set this code :
    MsgBox "This form was opened by button " & Me.OpenArgs

    Explanation :
    On calling the form, you set a text in the OpenForm command. This text is the OpenArgs. This text will then be available in the opened form as soon as it loads. Like this, you can detect which button has opened your form.

    This is not possible to perform with a macro! You must use code!

  12. #12
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    178
    Originally posted by Herman
    dump the macro's! Use code instead.

    Although I can't see the meaning on using 3 buttons to do exactly the same, here's a solution:

    On button A, set this code in the event OnClick :
    DoCmd.OpenForm "frmMyForm", , , , , , "A"
    Button B, use this code :
    DoCmd.OpenForm "frmMyForm", , , , , , "B"
    Button C, use this code :
    DoCmd.OpenForm "frmMyForm", , , , , , "C"

    In the OnLoad event of form "frmMyForm", set this code :
    MsgBox "This form was opened by button " & Me.OpenArgs

    Explanation :
    On calling the form, you set a text in the OpenForm command. This text is the OpenArgs. This text will then be available in the opened form as soon as it loads. Like this, you can detect which button has opened your form.

    This is not possible to perform with a macro! You must use code!
    thanks i got it to work.
    i just deleted the form and recreated it.
    the thing about the three buttons was that each button went to the same form but sent through a different employeeID.

    thanks for everyones help

Posting Permissions

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