Command Button Problems-MS2000 w/XP os

T

tmspurr

I'm unable to get my command button to work properly in
2000. Trying to open a form based on the contents of a
field in my current form. When I create the button to
Open Form based on contents in current form, create the
joined fields from one form to another, I can create the
button okay and it looks fine. Upon clicking the button,
I get the message
"The expression On Click you entered as the event properly
setting produced the following error: A problem occurred
while MsAccess was communicating with the OLE server or
ActiveX Control" *The expression may not result in the
name of a macro... and *There may have been an error
evaluating the function, event or macro.
I've never had problems with 97 an have been stuck on this
project for a couple months, not being able to get beyond
this. PLEASE, PLEASE HELP! I appreciate all you can do
for me!!!
 
A

Allen Browne

Firstly, check your references. From the code window, choose References on
the Tools menu. Make sure none are marked "MISSING". If this database was
originally in A97, you probably need "Microsoft DAO 3.6 Library" and the 2
compulsary ones (Access and VBA), and can deselect all the others (including
OLE Automation). More info on references:
http://members.iinet.net.au/~allenbrowne/ser-38.html

Next, uncheck the Name AutoCorrect boxes under:
Tools | Options | General
and then compact the database to get completely rid of this:
Tools | Database Utilities | Compact
If you want to know why, see:
http://members.iinet.net.au/~allenbrowne/bug-03.html

Thirdly, open your form in design view. Right-click the command button, and
choose Properties. Make sure the On Click property is set to either the name
of a macro, or else [Event Procedure]. Click the Build button (...) beside
this to open the macro or code window. Check that it looks right. If it is
the code window, choose Compile from the Debug menu to check that the entire
project compiles successfully.
 
P

Paul Johnson

Without seeing the code for your On Click event, I'm winging it here, but if
you change the first line of event subroutines (not your own custom subs)
from the way Access creates them, like adding or removing parameters, or
changing the sub's scope, then you will get errors similar to yours, if I
remember from my own experience. My error message was just a little
different, though, so this might not be the answer. I can reproduce this
message easily by removing the stock "Cancel as Integer" parameter from a
DblClick event sub:

The expression [On Click, Mouse Down, Key Down, etc] you entered as the
event property setting produced the following error: Procedure declaration
does not match description of event or procedure having the same name.

* The expression may not (etc.)
* There may have been an error (etc.)

To test it, you could go into the VBA editor and change the name of the
existing On Click event, and create a new one by selecting your control from
the choices in the code window's upper left combo box., then select the On
Click event in the upper right combo box. You can compare this to the line
you had (before changing the name), or just paste the existing code into the
new sub framework.

The catch is that the problem may lie in *ANY* of the event procedures on
your form, not just the one that posts the error when you click on it.. It
would be the same issue: a sub that has a change in parameter or something.
If Access creates "Private Sub myCtrl_KeyDown(KeyCode As Integer, ByVal
Shift As Integer)", then that's how it must read, or Access will balk, and
the error may show up in events fired away from the problem control.

Like I said, the error I'm referring to is worded slightly differently than
the one you received, so this could be off base, but it could be worth
checking.

Having said all that, I googled for the error message and found this
newsgroup post answered by Allen Browne (Microsoft MVP) at
http://www.talkroot.com/archivee/index.php/t-29984_Help_--_getting_crazy_error_message!.html

Check it out. I hope something here helps.
Paul
---------------------------------------------------------------------
Hi Neal.

The database is partially corrupt.

1. Delete the problem form.

2. Compact the database.

3. Close it.

4. At the command prompt, enter something like this. It's all one line, and
include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\My Documents\MyDatabase.mdb"

5. Open it and compact again.

6. Open a code window, and choose Compile from the Debug menu. Repeat until
there are no compile errors.

7. Import the deleted form from a backup copy of the database.

Post back for further instructions if that still doesn't solve the problem.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Neal Tipton said:
Dear Group:

I have a subform with two buttons neither of which work properly. When
clicked each one produces the following error message:

"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."

Earlier when trying to write the VBA for the buttons I found that whenever I
clicked the "..." button on the On Click property, it sent me to a module
for another form. I had to delete the buttons completely and start over
again before it would send me to the appropriate module. Now I get the
message above.

Something else, just to see what would happen, I tried creating a command
button ("Command 16", I think it was) with an On Click subroutine that
couldn't fail:

Private Sub Command16_OnClick()
MsgBox ("OK")
End Sub

Again, the same @$#%& message! What's going on and how do I fix it?

Neal Tipton
---------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top