• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2001
  • Last Modified:

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?
0
fitaliano
Asked:
fitaliano
  • 13
  • 11
  • 7
  • +1
1 Solution
 
Dale FyeCommented:
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
 
Rey Obrero (Capricorn1)Commented:
check if you have missing reference

from VBA window
tools > references

0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Posting the code would be helpful ...

mx
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
fitalianoAuthor Commented:
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
 
Rey Obrero (Capricorn1)Commented:


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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
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
 
fitalianoAuthor Commented:
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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Your vba project is Corrupted.  Hope the Decompile suggested above fixes it.

Do you have a backup ?

mx
0
 
fitalianoAuthor Commented:
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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
If you can fix it ... Wayne probably can:

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

mx
0
 
fitalianoAuthor Commented:
Yes, I have an old backup.
Is there anyway to delete these modules?
0
 
Rey Obrero (Capricorn1)Commented:
<Is there anyway to delete these modules?>

select the module and hit the delete key
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
You can *try* ...  importing everything into a new mdb - suggested above.

Otherwise ...  hit up EverythingAccess ...

mx
0
 
fitalianoAuthor Commented:
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
 
Rey Obrero (Capricorn1)Commented:
select the module from the database objects window, then hit delete
0
 
fitalianoAuthor Commented:
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
 
fitalianoAuthor Commented:
I forgot to attach the printscreen
Select-Module.ppt
0
 
Rey Obrero (Capricorn1)Commented:
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
 
fitalianoAuthor Commented:
Yes, I tried that but those modules do not appear in this window.
0
 
Rey Obrero (Capricorn1)Commented:
from Access window
Tools >Options
View Tab

check the box for Hidden Objects then click OK
0
 
fitalianoAuthor Commented:
I see all the modules but the incriminated 2...
0
 
Rey Obrero (Capricorn1)Commented:
can you upload the db?
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
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
 
fitalianoAuthor Commented:
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
 
Rey Obrero (Capricorn1)Commented:
fitaliano,

you are using a replica version of the db,
get the master db..
0
 
Rey Obrero (Capricorn1)Commented:
or try this

How to make a replicated database a regular database in Access
http://support.microsoft.com/?kbid=290052
0
 
fitalianoAuthor Commented:
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
 
Rey Obrero (Capricorn1)Commented:
??????
0
 
fitalianoAuthor Commented:
I ended up re-importing all the objects in another clean db
0
 
fitalianoAuthor Commented:
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
 
Rey Obrero (Capricorn1)Commented:
fitaliano, see my comment at http:#a33599071

mx just repeated my suggestion of importing all the objects in a new db
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 13
  • 11
  • 7
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now