0

I have a button on a form that opens a pop up form. I do this by using the DoCmd.OpenForm command in the on click event of the button. When I click the button on the form access crashes without error message or any type of crash report. When I open the debugging window and then click the button, the form opens as intended and there is no crash. I have dozens of buttons that open similar pop up forms, in fact most of them I just copied, pasted, renamed and adjusted some of the field references, inlcuding this one. Only one has this issue. It pretty much crashes every single time, unless I open the debugger first. The form is for new data entry. The data entry form has one main form, and a subform on it. The main form and subform are not linked, it´s mostly for design purposes. The main form has no elements apart from the subform and an unbound label in the header I use as a title. The subform has a textbox that is linked to a table element. Compress and repair does not help. The strange thing is that it works just fine if I first open the debugging window, if I don´t it just crashes. So I can't even figure out where it goes wrong, since it never does when debuggin is on, but I guess it's on the OpenForm and not the button click. No Idea what`s going on. I made a new form and deleted the old one, but got the same issue... Maybe some access bug I am not aware of?

Code for the button:

Private Sub Befehl2_Click()

DoCmd.OpenForm "neukategorie"

End Sub

All code that can be found on the subform of the pop up (one accept and one cancel button, nothing else with code on there):

Button cancel:

Private Sub Befehl11_Click()

If Me.Dirty = True Then Me.Undo
DoCmd.Close acForm, "neukategorie", acSaveNo

End Sub

Button accept:

Private Sub Befehl12_Click()

RunCommand acCmdSaveRecord
Me.Requery
MsgBox "Neue Kategorie wurde gespeichert"
DoCmd.Close acForm, "neukategorie", acSaveNo

End Sub

The textbox for data entry is linked to kategorie in the table kategorie_tabelle all the way on the left:

Database relationships

My Access version:

Version 2205 Build 16.0.15225.20028

My Windows install:

Microsoft Windows 10 Pro

10.0.19044 Build 19044

PATA
  • 49
  • 8
  • Some clarification: I need to open the debuggin window at least once after opening the project file for access to not crash. Once I have opened it once, I can then close it and the button will still work. Not opening it after opening the project file results in a crash when clicking the button. – PATA Aug 04 '22 at 07:18
  • 1
    Worth trying: 1. A full [Decompile](https://stackoverflow.com/a/3268188/3820271), 2. Import all Objects into a new database. – Andre Aug 04 '22 at 07:33
  • I'll give it a try. Is the procedure still the same using `accdb` files? In the link they are still on `mdb`. – PATA Aug 04 '22 at 07:48
  • 1
    Seems it still works, thx! I got a compilation error at step 7 `Compile Error: Method or data member not found`. Apparently there was some dead code I had forgoten to delete from a while ago. I got rid of it, and then decompiled and manually compiled again. It seems the weird crashing is fixed for now! Not sure if it was because of the decompile or the dead code I removed but it seems to work! – PATA Aug 04 '22 at 08:12

0 Answers0