Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
open form
Kim Boren 
      
16 months ago
Hello,
I have been working with the VBA DoCmd.OpenForm and I keep getting an 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." I do not have a server and I have not used the activeX control. I created a macro and it works fine. Can someone help me understand why the VBA will not work?
John Davy  @Reply  
         
16 months ago
Hi Kim
Please show us the macro that you created.  John
Kim Boren OP  @Reply  
      
16 months ago

Kim Boren OP  @Reply  
      
16 months ago

Private Sub TimeBtn_Click()
    
    DoCmd.OpenForm "TimeF"
    
End Sub
Kevin Robertson  @Reply  
          
16 months ago
This error usually occurs when there's a problem with the VBA code linked to the event. Even though you're not using an OLE server or ActiveX control, the error can still be triggered by:

1. Syntax or Typo Errors: The VBA code might have a mistake that's causing the error.
2. Invalid Form Name: The `DoCmd.OpenForm` method might be pointing to a form that doesn't exist or has been renamed.
3. References Issue: There could be a missing or broken library reference in your VBA project.
4. Event Property Mismatch: If the "On Click" event property is set to `[Event Procedure]`, but no corresponding VBA procedure exists or is incorrectly defined, this error can occur.
5. Corrupt Database: If your database is partially corrupt, it can produce such issues.
6. Macro Conflict: If you previously set up a macro for the same button, Access might still be trying to execute it, leading to confusion.

Troubleshooting Steps

1. Check the VBA Code
   Ensure that your VBA code is error-free.

2. Verify the Form Name
   Ensure the form name you're passing to `DoCmd.OpenForm` matches exactly (including spaces). You can double-check the form name in the Navigation Pane.

3. Ensure Event Procedure is Properly Linked
   Make sure the "On Click" property of your button is set to `[Event Procedure]`:
      1. Open your form in **Design View**.
      2. Select the button.
      3. Go to the Properties Sheet -- Event Tab.
      4. Confirm the "On Click" property is set to `[Event Procedure]`.

4. Compile VBA Code
   Go to the VBA editor (press `Alt + F11`), then:
      1. Click on Debug -- Compile [Project Name].
      2. Fix any highlighted errors.
      3. Save your changes.

5. Check References
   In the VBA editor:
      1. Go to Tools -- References.
      2. Look for any references marked as "MISSING."
      3. If you see any, uncheck them or resolve the missing reference.

6. Test in a New Database
   If the above doesn't work, try the following:
      1. Create a new database.
      2. Import the problem form and any related objects into the new database.
      3. Test the button again.

7. Check for Corruption
   To address potential corruption:
      1. Compact and repair your database: Go to Database Tools -- Compact and Repair Database.
      2. If the issue persists, try exporting the form to a new database as described in step 6.

8. Conflict with Macros
   If a macro works fine but VBA doesn't, it could be related to how Access is handling the event. Try removing the macro entirely:
      1. Delete the macro if it's still attached to the button.
      2. Reassign the VBA procedure to the "On Click" event.


Troubleshooter
Kim Boren OP  @Reply  
      
16 months ago
Kevin,

This really helps me better understand the error, thank you for such a detailed answer.

Kim

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 7:48:35 PM. PLT: 1s