Access ignoring my code

MarcMendel

Registered User.
Local time
Yesterday, 22:04
Joined
Jun 10, 2013
Messages
11
Hello Everyone,

I am writing Access VB code for the first time. Here is my first really basic question...

What would cause an Access DB to ignore any and all code that I write?? Is there a switch or something that tells it to read the code I've written? A line of code inserted in the "Declarations" perhaps? My DB is not recognizing any of the code I've written!? Nada, zilch, treating it like it didn't exist.

Heaping Praise to anyone who can help me fix this.
MM
 
Can you show us your code and tell us when it should run.
 
Hello Bob,

Thanks for replying. What is the difference between MDB and ACCDB formats? It is saved as an Access 2007 file?

Here is an example of what I'm talking about:

Option Compare Database
Option Explicit

Private Sub Form_Current()
SSN.SetFocus
Me.WorkPermitExpiration.Enabled = False
End Sub

Private Sub WorkPermit_AfterUpdate()

If Me.WorkPermit.Value = -1 Then
Me.WorkPermitExpiration.Enabled = True
Else
Me.WorkPermitExpiration.Enabled = False
End If

End Sub

Yet, when I open the form, focus does not go to the "SSN" field, and the WorkPermitExpiration field is enabled, not dimmed.

Thanks again.

MM
 
In the code window, click at the left margin to add a stop. Then when your code runs it should stop where you indicated and open the code window. If it doesn't stop, the event is not running.

the .mdb is the extension for A2003 and earlier and .accdb is the extension for A2007 and newer. A2007 and newer can create and modify older file formats but older versions of Access cannot even read newer file formats.
 
Hi Pat,

I put in a Stop, and the code window did not open up. So, my events are not running? What can cause that?

Thanks again for your help.
MM
 
Are the names of the non-executing event handlers listed in the form's Property Sheet -> Events?
 
So here is what is weird. I created a new database, added a few fields, wrote some simple code/events and everything worked fine. Then I closed the DB, re-opened it, and guess what...Nothing Works. Aaaargh!
 
Hi Spikepl,

You're spot on. I found a thread in another forum from a user with the exact same issue. You have to explicitly tell Access that a particular folder/location is "Trusted".

Everything works fine now. Lesson learned.

Thanks again for your help. much appreciated.

MM
 

Users who are viewing this thread

Back
Top Bottom