Link to home
Start Free TrialLog in
Avatar of fitaliano
fitalianoFlag for United States of America

asked on

Invalid Data Format in Access VBA

When I try to compile my VBA project in Access I get the following error message:

"Invalid Data Format"

How can I fix it?
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

When the error occurs, it generally give you an option to Exit or Debug.  Select Debug, and provide us with the code segment where the error is occuring.  Make sure you tell us which line is highlighted.

Additionally, you need to make sure that ever code module (whether it belongs to a form or a standard code module contains the following two lines:

Option Compare Database
Option Explicit

check if you have missing reference

from VBA window
tools > references

Posting the code would be helpful ...

Avatar of fitaliano


Wherever I click, I get the following message:
The expression On Click you entered as the event property setting produced the following error: Invalid Data Format
* 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 in evaluating the function, event or macro.
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this - to see where the error is occurring:

VBA Editor>>Tools>>Options>>General
*Temporarily* set Error Trapping to Break on All Errors.
Run you code.  It's should break in code at the actual error line.

After the issue is fixed ... be SURE to set back to Break on Unhandled Errors.

I think I identified the problem. I can pretty much open all the Class Objects and all the modules but 2 modules.
When I click one of them it gives me: invalid data format
When I click on the other one it gives me: out of memory
I tried to delete these modules but it doesn't let me do it.
I keep getting "invalid data format" and "out of memory"
I tried to import a working code from a .bas file but instead of replacing the exiting modules, it creates new modules adding 1 at the end.
Recreating the database will take me 1 month.
Your vba project is Corrupted.  Hope the Decompile suggested above fixes it.

Do you have a backup ?

This is what I had in the incriminated modules:
1) -------------------------------------------------------------------------------------------------------
Function fGetOut() As Integer
Dim RetVal As Integer
Dim db As DAO.Database
Dim rst As Recordset
On Error GoTo Err_fGGO
Set db = DBEngine.Workspaces(0).Databases(0)
Set rst = db.OpenRecordset("KickEmOff", dbOpenSnapshot)
If rst.EOF And rst.BOF Then
 RetVal = True
 GoTo Exit_fGGO
 If rst!GetOut = True Then
  'This is where you close down any forms, and quit the database
  'I leave this section as an exercise in creativity
  RetVal = True
 End If
End If
 fGetOut = RetVal
 Exit Function
 'Note lack of message box on error
 Resume Next
End Function

2) --------------------------------------------------------------------------------------------------------

Sub ShowUserRosterMultipleUsers()
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim i, j As Long
    Set cn = CurrentProject.Connection
    ' The user roster is exposed as a provider-specific schema rowset
    ' in the Jet 4.0 OLE DB provider.  You have to use a GUID to
    ' reference the schema, as provider-specific schemas are not
    ' listed in ADO's type library for schema rowsets
    Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
    , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
    'Output the list of all users in the current database.
    Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
    "", rs.Fields(2).Name, rs.Fields(3).Name
    While Not rs.EOF
        Debug.Print rs.Fields(0), rs.Fields(1), _
        rs.Fields(2), rs.Fields(3)
End Sub
Yes, I have an old backup.
Is there anyway to delete these modules?
<Is there anyway to delete these modules?>

select the module and hit the delete key
You can *try* ...  importing everything into a new mdb - suggested above.

Otherwise ...  hit up EverythingAccess ...

if I select the module and then hit delete nothing happens. The only way I know is to right-click and selct remove module. Am I missing something?
select the module from the database objects window, then hit delete
I did select the module in both the object navigation and the library (see printscreen attached) but I can't delete by hitting the "delete" button.
This could be a life saver, am I doing this right?
I forgot to attach the printscreen
close the vba window..
go to the Access window

you should see the database objects window as shown

select the module and hit the delete key
Yes, I tried that but those modules do not appear in this window.
from Access window
Tools >Options
View Tab

check the box for Hidden Objects then click OK
I see all the modules but the incriminated 2...
can you upload the db?
Try the Import into new mdb as suggested above. You might get luck.  Also the Decompile. But ... it's not looking good at this point.  When you cannot delete w/o those error messages, the db is *usually* hosed.

Can you upload ?  We might get lucky on a different system.

If all else fails, EverythingAccess can probably fix this for you ...

There you go...
Uploaded sample removed per Author's request: 
The sample had no bearing on the progress towards a solution.
Community Support Moderator

you are using a replica version of the db,
get the master db..
or try this

How to make a replicated database a regular database in Access
No I am using the design master. If you remove the design master from its location it will lose its Design Master property.
Just go to Tools --> Replication --> Recover Design Master to do any modification
to access the main menu click on the company logo and type "bvr"
I ended up re-importing all the objects in another clean db
I assigned more points to DBMax who suggested the solution but I also benefitted from Capricorn1 suggestions as I had to decompile and delete select objetcs.
Thank you
fitaliano, see my comment at http:#a33599071

mx just repeated my suggestion of importing all the objects in a new db
Whereas I do appreciate the pts and maybe a small Assist, the Accepted post (mine) was just pointing out what had ... already been posted by the other expert ... and further suggesting that you try that (importing/decompile) ... which in fact did turn out to be the fix.

You should hit the Request Attention button and change things around.