Topics Search

Enable fields VBA

Enable fields VBA
Views: 17
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:

Similar posts...

 

Subform fields lock/unlock enable/disable from userinput

Subform fields lock/unlock enable/disable from userinput Icon
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:
 

Access 2007: Enable Macros on Startup

Access 2007: Enable Macros on Startup Icon
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.
 

Modify properties of a relationship from VBA

Modify properties of a relationship from VBA Icon
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?
 

Changin report's fileds with VBA

Changin report's fileds with VBA Icon
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.
 

VBA Code on Form

VBA Code on Form Icon
I am trying to write a VBA access code that will help with displaying an error message to user trying to input new record into table, if 4 fields contain identical data. I have beenworking on this for 2 days straight now, and NOTHING seems to stop that record from inputing into the table.

Table Name: tblAwardsLog
4 fields: LastName , FirstName , Recommended , DateInitiated

All fields are TEXT fields. even DateInitiated

I have this Awards Log almost to where I want it, but just can't seem to get this one thing to work right.
 

How do I access numbered text fields through vba

How do I access numbered text fields through vba Icon
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?
 

Declaring from form to VBA

Declaring from form to VBA Icon
When I pass the information from a form to a function in VBA do I have to reformat dates and change the form information that should be numbers to numbers or is this something access will do on its own?

all fields on the form are unbound fields, does the form and vba consider them all strings or not?
 

Query fields (columns) do not apear in the right order.

Query fields (columns) do not apear in the right order. Icon
I have a query whose SQL is generated from VBA. There are 3 different tables involved in the query. My problem is that the query's fields do not appear in the correct order and by that I mean they in a different order than listed in the SQL. Here is the SQL: [SQL CODE]

If I rearrange the fields manually and close/save the query then open it again, they show up correctly. However once the VBA code is run, the query once again is generated with the fields being in the wrong order.

I tried creating a datasheet form based on the query, and the fields were in the right order right away. the problem is I can not use a form for this, because the fields used are dynamic.
 

VBA table population

VBA table population Icon
This is my first post and I am relatively new to VBA but not to programming in general.I have a small table that I successfully created a small search function for and now I am trying to find a way to add records to the table.

As of right now I have a main form with 2 buttons, one for the search and one for the add. The form for the add is finished except for the VBA in the back end. The fields in the add form correspond to the fields in the table but I can't figure out how to go about getting new records into the table.

Is it an SQL INSERT statement? Or is there a built in function in VBA thatwill allow me to do this?
 

Enable/Disable form fields based on a combo box selection

Enable/Disable form fields based on a combo box selection Icon
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