How to create dynamic VBA for Access code which will build

PJ99 :

I have been successfully using code such as:

Forms![MyForm]!Option1 = False

However, I now wish to make the above dynamic by using N = 1,2,3,4 etc. So the new code would look something like:

Forms![MyForm]!Option & N = True

Does anyone have any hints about how to make this work?

Many thanks.

HackSlash :

You want to avoid using bang notation !. Instead, use fully qualified references like this:

Forms.Item("MyForm").Controls.Item("Option" & N).Value = True

If you want to know more about bang notation there are SO threads like this one about it: Bang Notation and Dot Notation in VBA and MS-Access

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at


Login to comment


How to create route which is dynamic

How to create Sublime Text 3 build system which reads shebang

Dynamic Calculated Field in VBA Access

How to access Qt Build System project (QBS) variables in Qt code

How to create an VBA function in Access to replace any special character in table

How to create a dynamic favicon (which is depending on the browser color)?

How to create UserControl which support other element inside it in XAML code

Django: sidebar with dynamic URLs: how to dynamically create URLs which have dynamic folders in the path

How to create dynamic ranges and Improving vba Code

How access dynamic added controls from code behind

How to create a directory which will have access to the user who is installing a package?

How to let osascript not build applescript code which will not hit at runtime?

How to Create Dynamic Value Which Can use Entire App

access vba to create array

Build Table Name in VBA Access

How to create a function which eliminates repeated code

Excel/VBA - How to create a function which returns a list

Creating VBA code to reference cell text and create a dynamic Find & Replace

How to create source code with dynamic FM creation

Excel dynamic search vba code

How to create a global function which will access DB in express.js

Create a dynamic excel chart VBA

How to create a lookup function or VBA code which can return value against only first found result?

How do I create a VBA loop in Access for the code displayed below?

How to access a color in code behind which is defined in a xaml file

Create a method which create dynamic expression

How to create dynamic object list with files properties in excel in VBA

How to create a value which can be repeatedly used throughout XSLT code?

How to create a dynamic VBA code in Excel so that it always refers to a workbook with a changing name?

TOP Ranking