0

I have weird issue, code that was working suddenly started to generate an issue (i have no clue how to bypass it)

I have List Box (List2) on Form1, It's populated by:

SELECT [queryFormyTradycyjne].[Nr Maszyny], [queryFormyTradycyjne].[UID], [queryFormyTradycyjne].[Nazwa], [queryFormyTradycyjne].[UAP], [queryFormyTradycyjne].[Linia], [queryFormyTradycyjne].[GAP], [queryFormyTradycyjne].[Status] FROM queryFormyTradycyjne ORDER BY [Nr Maszyny]; 

queryFormyTradycyjne code:

SELECT Lista.[Nr Maszyny], Lista.[Nazwa], Lista.[UAP], Lista.[Linia], Lista.[GAP], Lista.[Status], Lista.[UID]
FROM Lista
WHERE Lista.isValid=False And Lista.UID Like 'FF*';

and if I'll double click on an item from List2 it supose to deliver value to the other form (AwariaZgloszenieNew), to the text field named txtNrMaszyny.

THAT was working just fine, since 2 hours ago. I actually didnt touch a thing in the code nor in any of these forms. I checked that on several PC's with different Access version installed. Same result: Error Method 'Item' of object 'Forms' failed (-2146500594 (800f000e))

My VBA code for double click event:

Public strSelectedItem As String

Private Sub List2_DblClick(Cancel As Integer)
Dim varItem As Variant

With Me.List2
    For Each varItem In .ItemsSelected
    strSelectedItem = .ItemData(varItem)
    Next
End With

DoCmd.OpenForm "AwariaZgloszenieNew"

[Forms]![AwariaZgloszenieNew].[txtNrMaszyny] = strSelectedItem

End Sub

Anyone with any kind of idea?

Eska
  • 203
  • 4
  • 13
  • Have you tried a compact and repair on the DB? – MatthewD Aug 27 '15 at 22:19
  • Im not quite sure how to do that. Edit: if u r talking about that button "Compact and repair" - after clicking it nothing changed... – Eska Aug 27 '15 at 22:20
  • On database tools tab of the ribbon menu there is a "Compact and repair Database" button. Back up your database first. – MatthewD Aug 27 '15 at 22:23
  • Suddenly my front end to the database it ~3mb, comparing to the backup of it i have - 40~mb. What just happened? :| Backup is kinda old.. – Eska Aug 27 '15 at 22:28
  • That's normal, it's the "Compact" part of "Compact and repair". – Andre Aug 27 '15 at 22:31
  • The compact takes out old data. When you delete records they are not actually taken out of the database. So those are removed. And when you do a query, I believe it actually creates a table "behind the scenes" that is left behind until compacted. https://support.office.com/en-ca/article/Compact-and-repair-a-database-6ee60f16-aed0-40ac-bf22-85fa9f4005b2 and here is some more info. http://www.databasedev.co.uk/compacting-and-repairing-ms-access.html – MatthewD Aug 27 '15 at 22:35
  • its not about the compact to be fair, im looking into vba code in my other forms - ots gone (even with a copy before compacting) I dont get it - why? only i have access to vba code (password protected and well, in corp noone take care about it) – Eska Aug 27 '15 at 22:37

1 Answers1

1

If "Compact and repair" doesn't help, there are two more things you can try.

  • Decompile

How does one decompile and recompile a database application?
Follow the steps in David-W-Fenton's answer to the letter.

  • Create a new database and import all objects from the old one.

Edit -- just saw your latest comment.
If the VBA code is gone, and no working backup available, some parts may be lost. For the future: during development, "Compact and repair" and (to a lesser extent) Decompile should be regular tasks.

I don't know how Decompile works with password protected code.
IMHO a better option to protect code in Access is by distributing .mde frontends instead of .mdb

Community
  • 1
  • 1
Andre
  • 26,751
  • 7
  • 36
  • 80