The Linux Page

Compile error. in table-level validation expression. (Error 3320)

Today I started having some problems with my tables.

I had a default value set to Now() and it would tell me that it was invalid. I removed it and the save worked.

What would really be the problem though?

The thing is the compiler is used against ALL your Visual Basic modules and if any one of them fails to compile, then you get the error. I had one error in one module. Definitions of external (DLL) functions such as GetUserName() and GetComputerName() must all appear before any function declation. I had the GetUserName() declaration such as:

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
    (ByValue lpBuffer As String, nSize As Long) As Long

This declaration allows you to access the GetUserNameA function defined in the advapi32.dll file. However, these declarations must all appear before the declaration of functions and procedures.

So the error was occurring because something could not be compiled. Not before the Now() was in error.

According to other users, the problem may also come from references being lost. In my case I quite doubted that was the case because it was working a few minutes earlier... although with Microsoft, you never really know what can happen. In any event, if trying to recompile everything (in your Visual Basic window, select click on the Debug menu and then select the first menu item: Compile <project name>) then you may want to check this page out as it includes many details on broken references:

http://www.accessmvp.com/DJSteele/AccessReferenceErrors.html