BlastWaveTech
New member
- Local time
- Today, 18:40
- Joined
- Apr 13, 2020
- Messages
- 3
I have a VBA module that contains a bunch of functions, and some of those functions are responsible for setting field values on a form. Right now, in the test environment, the form in question is just a standalone, but for production, the form will be moved to a different form (thereby becoming a subform to a new parent), and so all the form references in my code will need to be updated with the new path. Is there a way to store that form reference in a variable or table which I can reference in the code? That way, when the form/subform structure changes, all I will need to do is update the variable/table value instead of combing through potentially dozens of functions to make the update?
For example: I have a form called "MyForm", and a field called "My Field". This MyForm form will be renamed to NewSubform, and will eventually be embedded onto a form called NewForm. I want to write a function that sets the value of Forms!MyForm!MyField to "Done", but I want to 'store' the "Forms!MyForm" part in a variable called MyVariable so that in my VBA I can set the field value like this: MyVariable!MyField.value = "Done". That way, when it's time to move it to production, I only have to change the value of MyVariable to read "Forms!NewForm.Form!NewSubform" once. Does that make sense?
I keep trying different ways of doing it, but they all error out. It seems Access doesn't like using any sort of secondary reference as a Form reference.
For example: I have a form called "MyForm", and a field called "My Field". This MyForm form will be renamed to NewSubform, and will eventually be embedded onto a form called NewForm. I want to write a function that sets the value of Forms!MyForm!MyField to "Done", but I want to 'store' the "Forms!MyForm" part in a variable called MyVariable so that in my VBA I can set the field value like this: MyVariable!MyField.value = "Done". That way, when it's time to move it to production, I only have to change the value of MyVariable to read "Forms!NewForm.Form!NewSubform" once. Does that make sense?
I keep trying different ways of doing it, but they all error out. It seems Access doesn't like using any sort of secondary reference as a Form reference.