Does saving a Form also save associated VBA? (1 Viewer)

GaleT

Registered User.
Local time
Today, 01:15
Joined
Oct 18, 2019
Messages
72
Hi,
I recently lost some VBA changes and haven't figured out what happened. Recovery was simple so it's not a big problem but it caused me to question what I think I know about saving in Access. When I save from the VB editor it saves the entire database (its not split) so any form changes I have made are saved too. When I save from a form in design mode it saves changes on the form and the associated VBA. Is this correct?

Because of the lost VBA code I have started saving in the VBE and then saving the Form... which seems redundant but maybe I am missing something. :)

Gale
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:15
Joined
Aug 30, 2003
Messages
36,118
Yes, when you save a form from design view it saves the associated VBA.
 

GaleT

Registered User.
Local time
Today, 01:15
Joined
Oct 18, 2019
Messages
72
Thank you pbaldy... that's what I thought, I guess I simply didn't save the VBA changes. ouch!

Gale
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 04:15
Joined
May 21, 2018
Messages
8,463
Because of the lost VBA code I have started saving in the VBE and then saving the Form... which seems redundant but maybe I am missing something.
Not a bad habit to get into especially if doing any kind of looping code. I will write a lot of code and then have a bug that locks up the system. Often that code is lost.
 

GaleT

Registered User.
Local time
Today, 01:15
Joined
Oct 18, 2019
Messages
72
Not a bad habit to get into especially if doing any kind of looping code. I will write a lot of code and then have a bug that locks up the system. Often that code is lost.
Thank you MajP, per your suggestion I will continue to save the form and from the VBE. I haven't had a problem since I started doing that and it really doesn't take any time.

Thanks again, :)

Gale
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:15
Joined
Aug 30, 2003
Messages
36,118
For clarity, I don't think the intention was "click the save button in the VBE and then click the save button in design view". I don't think that would accomplish anything. It's "click the save button in the VBE now and then while you're coding a long process so you don't lose much if it all goes horribly wrong". In other words, save often, not double-save.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 04:15
Joined
May 21, 2018
Messages
8,463
The one that always gets me is looping a recordset. I will forget the move next and put it into an infinite loop. So any looping code I save before running.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:15
Joined
Aug 30, 2003
Messages
36,118
I've done that too, Now I use the code templates feature of MZ Tools. It's a right-click away, and drops in all the necessary bits.
 

zeroaccess

Active member
Local time
Today, 03:15
Joined
Jan 30, 2020
Messages
671
Yes, and vise-versa: you should notice that if you edit the VBA of a form, the form will be open in design view when you close the VBE.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 19:15
Joined
Jan 20, 2009
Messages
12,849
The one that always gets me is looping a recordset. I will forget the move next and put it into an infinite loop. So any looping code I save before running.
Yes, been there done that. And don't you just know exactly what you did a couple of seconds after you set off the code.:oops:

Press and hold Ctrl + Break to stop the code running. It can take a little while to stop.
Then you can edit the code. At this point I change something in the loop to make it stop looping, press Run and let it complete.
 

GaleT

Registered User.
Local time
Today, 01:15
Joined
Oct 18, 2019
Messages
72
Yes, and vise-versa: you should notice that if you edit the VBA of a form, the form will be open in design view when you close the VBE.
Yes, that is exactly what I see. But I am in the habit of opening the form in design view first and then I open the VB editor. So seeing the form in design view is exactly what I expect. But I think you are saying the form will automatically open in design view if I edit the associated VBA... which could happen if I open another module and make changes. Interesting... I didn't know that, thank you for mentioning it :)

BTW - the notification messages I receive from this forum are being blocked as spam. I contacted our IT department and they placed me under a "relaxed anti-spamming scanning rule". But I see another message was reported as blocked this morning so I'm not sure if the rule is working. My point is I apologize if I am slow responding but it isn't from lack of interest. :)

Thanks again for the tip zeroaccess,

Gale
 

Users who are viewing this thread

Top Bottom