Solved

Invalid Data Format in Access VBA

Posted on 2010-09-03
33
1,711 Views
Last Modified: 2012-05-10
When I try to compile my VBA project in Access I get the following error message:

"Invalid Data Format"

How can I fix it?
0
Comment
Question by:fitaliano
  • 13
  • 11
  • 7
  • +1
33 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 33598746
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

0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 33598781
check if you have missing reference

from VBA window
tools > references

0
 
LVL 75
ID: 33598942
Posting the code would be helpful ...

mx
0
 

Author Comment

by:fitaliano
ID: 33599039
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.
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 33599071


try doing compact and repair
Tools >Database utilities > compact and repair database

if problem persists,
* do a decompile
   see this link
http://www.granite.ab.ca/access/decompile.htm

* after that, create a blank db and import all objects
* open the VBA window and do
     Debug > Compile
     correct any errors raised

* do a compact and repair
0
 
LVL 75
ID: 33599098
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.

mx
Capture1.gif
0
 

Author Comment

by:fitaliano
ID: 33599184
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.
0
 
LVL 75
ID: 33599226
Your vba project is Corrupted.  Hope the Decompile suggested above fixes it.

Do you have a backup ?

mx
0
 

Author Comment

by:fitaliano
ID: 33599229
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
Else
 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
   Application.Quit
 Else
  RetVal = True
 End If
End If
Exit_fGGO:
 fGetOut = RetVal
 Exit Function
Err_fGGO:
 '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)
        rs.MoveNext
    Wend
End Sub
 
 
0
 
LVL 75
ID: 33599232
If you can fix it ... Wayne probably can:

http://www.everythingaccess.com/accessdatabaserepair.htm

mx
0
 

Author Comment

by:fitaliano
ID: 33599245
Yes, I have an old backup.
Is there anyway to delete these modules?
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 33599259
<Is there anyway to delete these modules?>

select the module and hit the delete key
0
 
LVL 75
ID: 33599266
You can *try* ...  importing everything into a new mdb - suggested above.

Otherwise ...  hit up EverythingAccess ...

mx
0
 

Author Comment

by:fitaliano
ID: 33599373
Capricorn1,
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?
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 33599402
select the module from the database objects window, then hit delete
0
 

Author Comment

by:fitaliano
ID: 33599592
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?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:fitaliano
ID: 33599625
I forgot to attach the printscreen
Select-Module.ppt
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 33599700
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
databaseObjectsWindow.jpg
0
 

Author Comment

by:fitaliano
ID: 33599714
Yes, I tried that but those modules do not appear in this window.
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 33599743
from Access window
Tools >Options
View Tab

check the box for Hidden Objects then click OK
0
 

Author Comment

by:fitaliano
ID: 33599820
I see all the modules but the incriminated 2...
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 33599841
can you upload the db?
0
 
LVL 75
ID: 33599844
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 ...

mx
0
 

Author Comment

by:fitaliano
ID: 33599857
There you go...
 
******
Uploaded sample removed per Author's request:
http://www.experts-exchange.com/Q_26451240.html
The sample had no bearing on the progress towards a solution.
 
_alias99
Community Support Moderator
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 33599914
fitaliano,

you are using a replica version of the db,
get the master db..
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 33599933
or try this

How to make a replicated database a regular database in Access
http://support.microsoft.com/?kbid=290052
0
 

Author Comment

by:fitaliano
ID: 33600082
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"
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 33600552
??????
0
 

Author Comment

by:fitaliano
ID: 33600592
I ended up re-importing all the objects in another clean db
0
 

Author Comment

by:fitaliano
ID: 33600609
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
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 33600636
fitaliano, see my comment at http:#a33599071

mx just repeated my suggestion of importing all the objects in a new db
0
 
LVL 75
ID: 33600994
fitaliano:
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.

mx
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now