Enable fields VBA

When I update a combo box to "Active," I want multiple fields to be enabled. I know the way to do it field by field. Example:

If Status = "Active" Then
Trial.Enabled = True
Else
Trial.Enabled=False
End If

Since there are several fields, is there a way to group those fields and name the GROUP of fields, so I don't have to do each one individually? I'm thinking something like this:

If Status = "Active" Then
Group1.Enabled = True
Else
Group1.Enabled=False

Sponsored Links:

Related Topics

Access 2007: Enable Macros on Startup
Has anyone figured out if it's possible to enable vba macros on startup using a script? In Access 2003 I used application.setoption to tweak a number of application parameters though I'mnot sure if I can use this to enable macros in 2007.

I know that I can manually enable macros through the trust center and I could also add a trusted location (could prob. also automate a registry update to do same). My preference though isto enable macros using a script as over 600 users will, on occasion, use these databases and I don't want to spend my days telling people how to enable macros.


Subform fields lock/unlock enable/disable from userinput
Re: Controlling fields in a subform from a combo list value VBA:
Field names:
cboActivity - this combo box lists the Activity Numbers (i.e 1.1, 1.2, 1.3, 2.1, 2.2, 3.1)
txtStartDate - this date field is an Input field
txtEndDate - this date field is an Input field
txtQuantity - this text field is an Input field
txtStartDepth - this text field is an Input field
txtEndDepth - this text field is an Input field

Goal / Solution Required: I would like the subform to lock the last three text fields (txtQuantity, txtStartDepth, txtEndDepth) on load.

I would like to enable these 3 fields for input based on the "cboActivity" value. The following condition to enable the text fields are:


Modify properties of a relationship from VBA
I have an Access 2007 database. In it, I have two related tables with a relationship that has Referential Integrity enabled. In a single instance, I want to enable Cascade Delete so thatall related records in a particular table can be deleted when the primary record is deleted.

Can I modify the property of the relationship from VBA to enable Cascade Delete on this one relationship, carry out the delete operation and then disable the Cascade Delete again?


Force user to enable macros
I've created a login form, but it's currently rendered useless by the Access 2007 security bar when opening the database, which disables the VBA in my form. Also, it puts a close button on the corner of my form which gives any user the option to access my data. Is there any way round this? I have already tried:

1) Fiddle with trust centre settings - this is not an option since a user could take the database to a different PC and the security bar would come back.

2) Change the VBA security setting in the registry - not an option since this would be done on form load via VBA, which is disabled.

I was thinking that maybe there is a way to invoke the security dialogue to prompt the user to enable macros or else immediately close the database.


Force user to enable macros
I've created a login form, but it's currently rendered useless by the Access 2007 security bar when opening the database, which disables the VBA in my form. Also, it puts a close button on the corner of my form which gives any user the option to access my data. Is there any way round this? I have already tried:

1) Fiddle with trust centre settings - this is not an option since a user could take the database to a different PC and the security bar would come back.

2) Change the VBA security setting in the registry - not an option since this would be done on form load via VBA, which is disabled.

I was thinking that maybe there is a way to invoke the security dialog to prompt the user to enable macros or else immediately close the database.


"Enable automatic reconnect" possible with VBA?
I had the problem that Access lost the connection to my MySQL db after a certain time period. Previously I connected via

Constr = "DRIVER={MySQL ODBC 3.51 Driver};Server=" & Server & _ ";port=" & Port & ";user=" & user & ";Password=" & pw & ";Database=" & Datenbank"

Now I connect via DNS set up in the windows control panel. There I checked the box "enable automatic reconnect". With the box checked the connection gets not broken anymore which is great. Now I would like to implement "enable automatic reconnect" in VBA so users of my application do not have to set up a DNS in Windows


Mcro security
I am new to Access 2007 but when I go into an application I have to hit the option button to enable the macros. Otherwise nothing runs on the app. Any button I hit does nothing to I enable the macros, which is funny because I do not have any that I made. What Access has I do not know. In any case, if I am enabling the macro to use the applications, why do I not just go into the trust center and enable it permanently?
I know this opens the application to macro viruses, but again if you have to enable it anyway, I am not sure I see the point.
Can someone please let me know if they there would be a reason for not just permanently enabling them.


If data changes in the field enable control else disable
In the Edit form whereby fields are referenced to a table. If any data changes in the field of Edit from (text or number or date ) I want the update control button to enable else disable. How can I do that ?


Enable/Disable form fields based on a combo box selection
Does anyone have an idea of a code that I could use to enable or disable form fields based on a combo box selection "findPatient". Say, the form opens and the combo box is null, then the form fields are disable but after a selection is made they become enabled.

Please anyone. I will attache the file for your view and code suggestions.

Please check the first form that opens on start up


Digital signature
I just converted a database from 2003 to 2007 and got my first look at the 2007 format. When I opened the db I get a security warning saying certain content has been disabled. I clicked the options button which said the potentially harmful content is VBA Macro. I was able to enable it for this session only, but I would like for it to run right whenever anyone opens it.
I read that the macro must have a digital signature, and followed the path to select one, but there were no certificates to select. I'm sure I probably wouldn't want to enable all macros, but none of the other paths lead me to anything useful.
How can I get by this, and will I need to do it for every db I create or convert from here on out


Disable and Lock All Feilds wiht a check box
I am using MS 2007 and have a form that I would like to lock = yes and
enable = No on all fields.

I would like to do this by checking a check box. I would also like to have the lock = no and enable = yes when I uncheck the check box.


Change Series Name in Legend in Chart Report using VBA
I asked this question in the report forum, but wasn't able to solve my issue.

I know that it must be possible to change the series name in a chart using VBA, but am not at all experienced with writing it myself.

Is anyone able to help with some code to enable me to do this?


Detect When Two Related Fields are Dirty
I have a form for entering Staff Names and what I am trying to do, is only enable the Save Record button once both a first and last name are entered.
I created a Form_Dirty sub and in it, I was checking the value of the two text boxes. If both were not Null then I'd enable the save button. This however only works when both are not null and when they are initially being entered, only one is non-null when the OnDirty event is run.
So I tried using the Dirty Event in each text box and having it call the Form_Dirty procedure. However, the second text box to be filled is still Null when its OnDirty event fires, so the buttons still do not enable.
I tried using AfterUpdate instead of OnDirty, for the text boxes, but those events don't fire until the user has exited both text boxes.
I was hoping for something that could detect that one text box was edited and that the other was in a state of being edited and at that point, enable the save Button


Null Handler for multiple fields
Evening all,

The VBA/Access question of the day is: Is there a way to get VBA to automatically populate fields with "Undefined" or "Unknown" or "N/A" when those fields do not contain any data. I really don't want to have to NULL define every single field individually or rename the fields and run a loop. If anyone knows a way to do this, I could really use the input and would be very greatful for the knowledge


VBA Code Not working
I may not be typing the code correctly, but I am wanting my two fields on my form to be disabled when the checkbox is checked, and then enable the fields when the checkbox is not checked or unchecked. The VBA code I am using is:

Private Sub Flag_Lock_box_Click() Dim c As Control If Me.Flag_Lock_box = Yes Then Me.Flag_Lock_box = True Me.Name_First.Enabled = False Me.Name_Last.Enabled = False End If If Me.Flag_Lock_box = No Then Me.Flag_Lock_box = False Me.Name_First.Enabled = True Me.Name_Last.Enabled = True End If End Sub

And it works for locking the record when the checkbox is checked, but it disables the checkbox so I can not "uncheck" the box if editing is needed. What modification do I need to make in order to be allowed to uncheck the box and modify the record, if needed?


How to force user to enable vba macro?
So, I need to make sure that there is NO SECURITY WARNING message when opening my database in Access 2007, because I have some procedures than will not function otherwise.


Using module to modify form
I've managed to create a form that accepts usernames and passwords and once a user enters a correct username/password the form closes and opens the mainpage of the database (simply has many cmd buttons to allow users to open reports, view/update data etc.). Each user has a different level of access (there are a total of 3 levels of access). Instead of creating a form for each level of access that has the appropriate buttons I'm hoping to use one form and simply use some form of VBA to enable/disable the buttons. I'm thinking this would be best done in a module, however, I'm not sure of how to set text box/cmd button properties from inside a module. if this is even possiable.

Should I attempt to use only one form w/ VBA to enable/disable all the buttons depending on access level or just stick w/ my current plan and make 3 seperate forms, one for each level


Changin report's fileds with VBA
I have a report, that is based on a query. I want all the fields in the query to appear on the report. The query uses 3 tables for its data, and one of tables in constantly being deleted/recreated from vba and primary key is being assigned to one of the fields.

Each time the table is recreated, 2 of the fields that are in the query, have their names and data changed. My problem is that when that happens, the query works fine since its SQL is being changed in VBA to reflect the new changes, but the report shows an error in the fields that have beenchanged in the table.

Is there any way for me to dynamically change the report's fields, to the once used in the query.


Unable to click "Enable Content" unless in Design View
I've just designed a user login screen and tried distributing it on a client PC. The usual warning came up but I noticed I can't click the Enable button.

The only way I can click the enable button is to right click and select Design view. I haven't notice this behaviour before when developing in Access 2007 (I am using Access 2010 now).

This would of course cause a problem when I distribute it later as ACCDE to end users. Any idea why I need to go into design view to click the Enable content button?


How do I access numbered text fields through vba
I have a form in access with 8 fields named (Data1, Data2, Data3, etc.). I would like to change their feature via VBA dependent on user action.

Can I code a do loop that can reference each of the Dataxx fields. for example.

For I = 1 to 8
myField = Data & cstr(I)
myField.FontBold=true
next I

I know this wouldn't work, but is there a way to calculate and use a field name?