MS Access: Repair broken button/control/vba - vba

is there some way to repair broken functionality in ms access, like recompiling the thing?
I have a button on a form that is supposed to run vba code when clicked. The button no longer works, after like a couple of months. Except for the button getting focus nothing happens. I have tried the compact and repair option in access with no luck. The code works fine btw. I have made a new random button somewhere else on the form and literally copy pasted the vba code from the on_click event of the broken button to the new one, and on the new button it works perfectly. No problems at all. The old one, however, nothing. No matter what I do. I deleted the vba code in the on_click event, saved, closed and opened access again, then reentered the code. Still nothing. I tried removing certain functionality from the button by removing line by line, trying to see if any one line is the issue. Nothing again, no errors are being displayed, I don't think the button even runs the vba code at all.
In case someone wants to look at the code:
Private Sub Befehl107_Click()
[NavigationSubform].Form![stoffe_abfrage subform].Form.FilterOn = False
[NavigationSubform].Form![stoffe_abfrage subform].Form.Requery
Me.FilterAlleLink = "Alle"
Me.FocusDummy.SetFocus
End Sub
The button basically turns off the filter on a subform, requeries the form, sets the value for a textbox on the local form, and then gives focus to another textfield. Nothing complex really. I have 3 more buttons of the same type on my form that manage different filters for the same subform with almost identical code, they all work fine. Just this one broke.
Again, the code works fine if I make a new button, but on the old one it does not do anything.
Obviously I can just replace the button, but that would be annoying if down the line there is other functionality referencing it etc. So I was wondering if anybody encountered a similar problem and has a solution. Given that I have only worked with access for like 2 months total and already have this issue I hope there is some way to repair this more quickly, since I am now assuming that this will happen more frequently. Not sure though, maybe someone with more experience knows if this is common.
Edit: I just checked if literally copy pasting the broken button itself works and yes. I copy paste the broken button somewhere else, then copy paste the vba code from the broken button to the copy, and the copy now works...

Related

Why would an Access 2010 form button with an embedded "openreport" macro and a "where" filter, stop working until I add a new button?

I decided to "tweak" an existing database to further manage multiple sources of income.
I copied the working database and created a "modification copy", just in case I messed things up horribly.
In the modified version, I have a button on a form (in fact, two different buttons with similar macro properties, just directed to do the same function to different reports.
The properties are your standard macro with an openreport, and a "where" condition.
Here's the problem. The macro has worked in the past, and continues to work on my "pre-modification" operating database.
On the modified database, after ensuring all the parameter elements are entered correctly, I can change the "view" to report view, and the macro seems to work just fine until I close the database.
As soon as I open the database, the buttons produce an error. See pic below.
The only way I seem to be able to resolve this odd button macro issue is by going into design view and adding a new button. I've discovered...I don't even need to embed a macro, just adding a new button seems to renew the macro operation...until I close and reopen the database. Then, I have to add a new button again to get the open database's macro to operate.
I can delete the new button added, and still have the macro buttons work, until I close and open the tweaked database.
I have zero VBA coding knowledge. I use Access's macro building tools and typically have to visit sites like this if I need to learn a new "trick" to get my database and it's various tools to do something.
I recently explored with the "subform" that can be seen above in the open form pic with the error message. My guess is that maybe that subform is somehow causing my macros to continuously fail???
Thanks for any help!

Access Form suddenly stopped executing VBA code (solution) (Access365, Windows 10)

This is not a question, actually it is how I fixed it.
I have an Access Form that is my start up and, of course, opens automatically. I have 1 button that runs VBA code, and suddenly, it stopped working, as well as the VBA code in OnFormLoad event. The buttons with MACRO code, though, worked fine.
Solution: I went to Design View, added a new button with the VBA code in OnClick event: msgbox "Works" (can be anything). Once clicked on the button, the code executed normally and, "magically", button and OnLoad script started working again. I have no reasonable explanation for that...

UserForm Option Button Controls Crash Excel After Toggling at Runtime

I'm having a problem with radio option buttons on a UserForm I have created in excel. When the UserForm is loaded it is defaulted to OptionButton1. If I toggle to OptionButton2 and then toggle back to OptionButton1 excel will be unresponsive and crash when I close the form. If I just toggle to OptionButton2 and close the form or don't toggle them at all, everything will be fine. It only happens if I toggle more than once in a given runtime. Also, the option buttons are on a frame on the userform if that makes any difference.
I have commented out ALL code that is triggered by events attached to the controls and it still happens. Also, the code works perfectly fine in the case that I only toggle the options once. It will crash simply by changing the option to 2 and back to 1 without executing any other code. I have another option button group on the form and I don't have any issues with that group. I can toggle them as many times as I want.
I'm not able to share my actual workbook and have been unsuccessful recreating the problem in an example workbook. I'm not sure what else I can provide that would be of use. If anyone has any suggestions based on my description of the problem, it would be greatly appreciated. I have run out of ideas.
Things I've tried:
Removing all code associated with the controls
Changing and removing the group name for the set of option buttons
deleting the option buttons and remaking them
changing the names of the option buttons
copying and pasting the existing working option buttons and renaming them
EDIT: I was able to save as on my original workbook and delete everything out except the working and broken option controls. Here is a link to the sample book which is a bare skeleton of my actual workbook:
Link to workbook example.
Even with everything gone, the problem still happens. If you open the userform, you can toggle between the "Option A" and "Option B" buttons, but if you try to toggle between "Option 1" and "Option 2" excel will crash when you close the form.
Your User-Form and /or controls are corrupt. In line with what Commitern suggested, instead of full export and recreation, try this:
1.Delete your faulty user form. in this case `Test`.
2.Save and close Excel.
3. Go to C:\Users\<<yourusername>>\AppData\Local\Temp\VBE
4. Here delete all the exd files.
5. Re-open workbook add new form, name it `Test` and all option buttons.
All works fine.
Remember if you try to add a new user form and rename it as the old one Test without saving the file, you will get error.
https://support.microsoft.com/en-us/kb/244238

Access VBA: How do I make the VBA editor stop auto-filling values?

I already turned off auto-syntax check but this problem still persists. Whenever I try to modify a time, let's say from 08:30:00 AM to 08:30:05 AM, Access sometimes fills in a zero after I backspace to clear the 0. It forces me to have to quickly change the value otherwise it gives me an annoying pop up message saying syntax error....but the editor caused the error, not me!
How do I fix this? Please help me fix this.
This happens when code is running, which forces Access to constantly compile the VBA source code.
Typical example: a form is open that uses the OnTimer Event (has TimerInterval > 0).
To prevent this: Close all forms while editing code (Design view is ok).
If it's not forms, press the "Stop" button in the VBA toolbar (the blue square) to stop all running code.

Can't View VBA Form

So I created a form, and have been using it for a while.
All of a sudden today it stopped working. Other forms load and can be viewed but not this one.
The weirdest part is that the controls still respond!
So I can't actually see the form but I can still interact with it. (only using keyboard no mouse clicks are responding) I know the form is enabled. But I simply can't see it! I have restarted excel, and the whole computer.
I even completely removed all code in the userform to see if I could get the blank shell to load, and while I can tell it loads (it disables everything in excel until I use Alt+F4) it still won't be visible. I have checked the Enabled, All Colors, Captiuon, Width, Height, Top, Left, StartUpPostion, SpecialEffect, Zoom, DrawBuffer properties and everything is fine.
I have also Exported and reimported it and still simply nothing. Also tried importing it into another Workbook, nothing. I at my wits end (not that it's very far to reach!)
Also, I can still see the userform in the designer I can still edit it, I get NO errors. This happens not only when calling the form in code, but even when running it right from the designer.
Any one ever have this issue? Any ideas or solutions?
The issue ended up being the Top and left properties. While I did check them, they way I checked them was not accurate; I still have no idea why, but I think it defiantly has something to do with dual monitor setup.
The way I tested double checked the forms top and left properties was by creating a new form and adding a button on the button click event I had a msgbox show the top and left properties of the form at time of clicking.
I then moved the new form to where I wanted the form that woudn't show to be and clicked the button; I then set these values to the form that wouldn't show.
I tested this location and made sure to match the properties with the values I wanted multiple times and it didn't work.
For some reason the values needed where about 1000 digits off (instead of 250 I needed to use 1250) even though I had set the form right where I wanted the new one to be and made sure to save the properties when they matched what I wanted