Code To Disable A Field Based On The Values Of Another Field

Nov 10, 2005

If I have the following Code to disable a field based on the value of another field:

Private Sub lstAgreementType_AfterUpdate()

If Me.lstAgreementType.Value = "BN" Then
Me.txtSenateAandCDate.Enabled = False
Else
Me.txtSenateAandCDate.Enabled = True
End If

End Sub

But I also need it to disable the field is equal to "BA" or "BT" as well, how would I add that to my code?

View Replies


ADVERTISEMENT

Forms :: Table Form - Disable Fields Based On A Value Of Another Field

May 27, 2013

I have a table form (I want to have many records available in the screen)

I want to disable fields based on a value of another (main) field.

The fields are check boxes, so the automate formatting is not available.

I use the VBA code below:

Select Case name1
Case "POINT"
Me.sf1.Enabled = False:
Case "SIDE OUT"
Me.sf2.Enabled = False
Case Else
Me.sf3.Enabled = False
End Select

but the fields become disable to all records, not only to the records under the right condition. Why?

View 2 Replies View Related

Importing Records From Text File Based On First Character Or Code In One Field

Jun 12, 2013

I have a file that I need to import on a regular basis. There are two different issues with the import:

1. the first digit in the file indicates if it is a record I want to keep. In this case a 1 indicates a repair record and an 8 indicates it is just information such as email, contact info etc.

2. I have a field in the file that may change the import specifications

For example:

If the record is a Non wheel repair then column 167 is a 50 character description
If the record is Wheel repair then column 167 is a 28 character description and the remaining 22 characters are broken down into 10 different fields

So I need to do the following

1. Read the first character in the line and determine if it is a number 1 and if not discard it
2. Read a field in column 109 that is two characters long and if it says it is a wheel repair the import will break column 167 -216 down to the appropriate 11 fields and if it is a non wheel repair it will import columns 167 - 216 as one big description field.

I have used the import specifications with Access but it seems this will have to be done in code in a module or something and I am not very good with VB. (only know the basics)

One other issue is I have dates in the file that are 130225 and 1302 (so full date and then Year/Month) if i take out the / date separator in the import spec the full date works but the Year/Month doesn't.

View 9 Replies View Related

Field Values Based On User Selection In Combo

Dec 9, 2005

Hello,

I'm stuck! I want to create a form which has a combo box where you select
someone's name, and their address appears in another text box on the same form. The names and addresses are in a table called "cardholders".

I'm doing separate combos for first name, surname cos I think that's the only
way you can do it.

The fields in the table are credit_add, credit_name & credit_surname. The combos are called "cardholder name" "cardholder surname" etc. This is the code in the text box where I want the address to appear:-

=DLookUp("[credit_add]","cardholders","[credit_name] = '" & [cardholdername] & "' And [credit_surname] = " & [cardholdersurname])

Can anyone help?

Thanks.

View 3 Replies View Related

Queries :: Match Based On Multiple Values Within One Field?

Sep 22, 2014

For my study on academic research I need to match patents that refer to academic research as prior work with the actual prior work.

I have two tables (see attached images below).

One regarding AcademicPublications (AP), which is neatly organized with title, year, journal, volume, pages, first author, etc... 480,000 rows

One regarding Patentswhere all this information is hidden within one field, in the most messy way possible... for instance, a field could have:

Quote:

Sugita et al, "Nonsurgical Implantation of a Vascular Ring Prosthesis Using Thermal Shape Memory Ti/Ni Alloy (Nitionl Wire)," Trans. Amer. Soc. Artif. Intern. Organs, vol. 23, pp. 30-34.

or

Quote:

Willingham et al., Cell 13, 501-507 (1978).

Or many other ways.

I want to create a new table that is set up like this:

Patents.PatentNumber | AP.ID | Patents.Reference | AP.Title | AP.Year | AP.Volume | AP.PageStart

The question is: How do I match different fields from one table on one field of another and make it return another field (the ID)? Some references are too horrible to match, but I need as many as I can get.

I can imagine two queries would give me the bulk:

A match in [Title] AND [Year]

A match on ([SourceTitle] OR [AbbreviatedSourceTitle] ) AND [Volume] AND [Year] AND [PageStart]

I understand that I have to make use of the Like "*"&[value]&"*", but how do I make it return the matching ID?

View 10 Replies View Related

Forms :: Limit Values Of Combo Box Based On Value Of Another Field

Aug 25, 2014

Field B is a combo with the options of : 100% Availability, 75% Availability, 50% Availability, 25% Availability, OR Not Available

If I choose "Present" in Field A, I want the "Not Available" value to disappear as an option.

View 2 Replies View Related

Forms :: Changing RecordSource Of A Form Based On Field Values?

Feb 16, 2014

I have a simple add form that will add an entry to one of two tables: Box 1-1, or Box 1-2.

They have the exact same fields. In the add form, I want the user to specify a Rack field and a Box field. Box 1-1 would be Rack 1, Box 1. Box 1-2 would be Rack 1, Box 2 (there will be more tables later, but just using two for now until I get it working).

But right now my form always adds to the table Box 1-1 - I can't get it to switch.

I've added the code I have so far below. The first part is what I'm having trouble with, the second part just uses a Submit button to add a new record - I'm just including it in case it's interfering in some way I'm not seeing. I'm running Access 2007.

Code:
Private Sub Switch_BeforeUpdate()
If Me.Rack.Value = "1" And Me.Box.Value = "1" Then
Form_Add.RecordSource = "Box 1-1"
ElseIf Me.Rack.Value = "1" And Me.Box.Value = "2" Then
Form_Add.RecordSource = "Box 1-2"

[Code] ...

View 7 Replies View Related

Modules & VBA :: Adding Various Values Based On Select Case To Value Of Field

Oct 1, 2014

I am trying to add various values based on Select Case to the value of field. The problem I face is that each time when I get different Case in select statement, the value of the field rather changing adds the value on top.

Code:
Private Sub ProductID_AfterUpdate()
Dim qflPrice As Variant
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sqlQry As String
Dim instID As Integer

[Code] .....

View 5 Replies View Related

General :: UPDATE Field In Table Based On DISTINCT Values

Mar 12, 2013

Below is a sample of the table with the data. I manually added the 1 and 0 to the hc_Year field. However, I would like to create an Update query that will add a 1 to the hc_Year if its the first instance of PIDM & regsYear and add a 0 to the records that are not the first instance.

PIDM | regsYear | hc_Year
52 | 2009 | 1
52 | 2010 | 1
201 | 2007 | 1
201 | 2007 | 0
201 | 2007 | 0
201 | 2008 | 1

View 6 Replies View Related

Forms :: Sort Values / Text Based On Active Field

Feb 5, 2014

In a form is there a way to change sort order based on which field is active?

I'm using a Split Form which gives me the ability to sort by clicking on the header name ans selecting sort. This slowing things done since my workload is heavy.

View 3 Replies View Related

Queries :: Query Based On A Form Which Had Field Names And Some Values

Feb 26, 2014

I have a table listing about 20 elements as field names eg FE, CR, NI, TI and so on.

I have built a form which has a combo box listing these elements by selecting "fields" in the property settings of the combo box & next to this combo box i have 2 text box's where the user can input Min & Max values to pass on to the query.

E.g., FE (chosen from the combo box) value between (Text box1) and Text box 2.

I can run the query to give me values between the 2 text box's by using the following formula in the criteria (Between textbox1 and textbox 2).

The issue i have is to be able to select the element from the listbox, input the min & max values identified and be able to pass this to a query so the query can filter based on the field and values passed?

View 3 Replies View Related

How To Clear Values In Specific Fields Based On Updating Value Of Another Field

Feb 27, 2015

I am working on form where the user selects either "IN" or "OUT" from a dropdown of field name "CheckOut" in Frm1.

If they select "OUT" they will in turn need to fill in 2 additional fields. When they change the value back from "OUT" to "IN",

I want those other fields to be cleared of data for just this record so next time they change back to "OUT" from "IN" those 2 additional fields are already blank.

View 1 Replies View Related

Forms :: Use One Field To Enable Or Disable Another Field

Jun 10, 2013

I have a form with a checkbox (Is a Work Permit required?)and a date field (Work Permit Expiration date). I want the date field to be dimmed when the form opens. I want the focus to go to the checkbox first. The checkbox asks whether a youth is required to have a Work Permit. if the user checks the box (the youth needs a Work Permit), then I want the date field to be undimmed and available to the user to put in the Work Permit Expiration date.

I've tried using the checkbox afterupdate property to enable/disable the Work Permit Expiration date field, but no luck. What am I doing wrong? How do I make this work?

Private Sub WorkPermit_AfterUpdate()
If Me.WorkPermit.Value = -1 Then
Me.WorkPermitExpiration.Enabled = True
Else: Me.WorkPermitExpiration.Enabled = False
End If
End Sub

View 8 Replies View Related

Modules & VBA :: Create Unique Reference Number Based On Field Values For Record

Jun 18, 2015

I want Access to automatically generate a reference number for a record based on the values in on two other fields for a given record using a form.

The first field is called Operation Number.

The second is Bag Number.

The reference number needs to be in this format: 19C.3.1

Where 19C is the Operation Number, 3 is the bag number, and 1 is automatically generated. Additionally I need the last number --the automatically generated one--to go back to 1 if with each new bag number.

This is kind of like library catalog numbers. Not sure how to do this.

View 2 Replies View Related

Modules & VBA :: Code To Check Contents Of A Field In A Table Where Another Field

Sep 11, 2013

I am trying create some code that checks if the contents of the status field in a table is "Authorised" where the ID = something specific for multiple records. If all records witht the specific ID are "Authorised" Then generate a new record in another table. Where to start, perhaps a Dlookup?

View 1 Replies View Related

Sum Field Values Only If Another Field Values Meet Criteria

Mar 20, 2015

I need for Access only to sum the "hours worked" of my payroll data, only if another field, "pay code" meets a certain criteria.

In Payroll, some codes are used to designate actual hours worked like REG (Regular Hours) and like OTS (Overtime Straight) while other codes are added as "premiums" to these hours and do not mean that you actually worked those hours, like OTP and HOD (Overtime Premium & Holiday Premium). The hours are only added as a reference to the actual hours worked they are attached to. Their units should not be counted as hours worked.

I want Access to 1) Group By Cost Center, 2) Sum "Hours Paid" that are tied to a REG or OTS (only), but 3)Sum the Earnings for all pay types.

Basically, (in excel-like terms: Hours Paid Column= SUMIF of Paycode = REG OR OTS. But Earnings Amount Column= Sum of all Paycodes)

Cost Center
Job Type
Hours Paid
Pay Code
Earnings Amount

20530
Security Guard II
7.5
REG
190.37

[Code] .....

View 14 Replies View Related

Limit A Field To User Defied Values Depending On The Input Of Another Field.

Nov 23, 2005

Hey all,

I have two fields 1 & 2

field 1 is a simple combo list of user defined values ie A, B, C or D

Field 2 relates to a attribute of the data in field 1 and is not always the same for A, B, C and D. i.e

A could have a,b,c,d or e
B could have c,e,f,g or h
C could have a,g,h,i or j
D could have v,w,x,y or z

I would field 2 to have a combo box which only displays a,b,c,d, or e when A is chosen in field 1; c,e,f,g or h when B is chosen; etc

How do I do this?

Cheers all,

Matt :confused:

View 2 Replies View Related

Tables :: Linking Multiple Field Values To A Field Selected From Combo Box

Feb 16, 2014

I'm pretty good with setting up a very simple database such as inventory, profiles, etc.. However I'm creating a database to keep track of a football (soccer) team's players and match statistics.What I have so farsample attached)

Tables:
* Players - PlayerID, Fname, Lname, position, goals, assists, etc (all details regarding a player)
* Position - Positons (Table containing positions eg: defender. Data is selected in player's form as a combo-box)
* Competition - Competition types (Cup, League, Friendly. Data is selected in Match's form as a combo-box
* Venue - similar to Competition table
* Opponent - Similar to above two tables
* Match - MatchID, Competition, Venue, etc (form corresponding to table attached)

Forms:
* Player form
* Match form

Now as shown in the sample, I choose players using the combo-box. Then whatever stats they had during the match are entered on the fields provided. How to link the player (selected using combo box) to the stat fields (goals, assist, YC, etc).

View 1 Replies View Related

Forms :: Insert A Field That Sums Up / Aggregate All Values Of Field

Jul 25, 2014

i want to add a control in that form that sums up and aggregate all the values of field called [amount] based on the value of [Name_Patient] as criteria

View 2 Replies View Related

Editing Field Values That Get Summed Up - Resets Total Field

Apr 7, 2015

I have several fields that I fill in on a form and they all need to add up in the last field. The first way that I tried this worked good for the initial data entry on the form. However if I need to edit one of the fields in the form then it resets the TotalCost field and I have to enter all of the numbers again. Is there some way that I can make this work? Or is this an Access quirk I will have to live with?

I tried to do this two different ways.

Here is the code for the first method:

Option Compare Database
Dim C1 As Long 'For Total Cost
Dim C2 As Long 'For Total Cost
Dim C3 As Long 'For Total Cost
Dim C4 As Long 'For Total Cost

[Code] .....

This way works great the first time that I tried it, I had to re-enter info in all the fields if I wanted to change one.

Here is my second method:

Which didn't work, i received an error message:

"The expression After Update you entered as the event property setting produced the following error: Invalid outside procedure."

And then nothing changes.

Code:
Option Compare Database
Dim C1 As Long 'For Total Cost
Dim C2 As Long 'For Total Cost
Dim C3 As Long 'For Total Cost
Dim C4 As Long 'For Total Cost

[Code] ....

So I know this second method is incorrect.

View 3 Replies View Related

Concatenating Multiple Field Values Into One Field Separated By Commas

Nov 18, 2014

I am trying to create a list of values in a field separated by commas. I have done this in a query as follows:

[Field1]&", "&[Field2]&", "&[Field3] and so on.

However, when Field2 is null, the result is two commas between Field1 and Field2, but I only need one. What function can I use to eliminate the extra commas when fields used in the concatenation are null?

View 10 Replies View Related

Tables :: Auto Populate Field Based On Answer Of Another Field In Same Table

Feb 28, 2013

Within my table if Field 1 has an answer of Self (from drop down), then, I would like Fields 6-12 to auto populate; however, if Field 1 does not have an answer of Self, then leave Fields 6-12 blank.

I am not quite sure how to lay this out. I am using Access 2010.

View 8 Replies View Related

Forms :: Autofill Field Based On Related Field In Previous Form

Jun 30, 2015

I have my Assets form and the primary key is the ChargerID, in this form I have an "Add New Job For This Asset" button, which opens up the Jobs form at a new record.

How do I make it so that the ChargerID field is automatically filled with whatever the previous record was instead of being blank.

For example if I have Charger12345 open in the Asset form, I'd like to click the Add New Job button and it automatically have Charger12345 in the ChargerID field of the Jobs form.

View 5 Replies View Related

Make Field Auto Populate Based On Value Of Field In Another Table

Mar 4, 2008

I'm creating a database that keeps a track of questions and scores.

The questions in the database need to be dynamic and are changed frequently.

I have a scorecard table which keeps a record of scores and the applicable question at the time the record was saved. I need to do this because in 6 months time we may want to provide feedback. As the question may have changed we need to be able to refer back to what the question was.

I want the question field in my scorecard table to populate with the value in my question table.

I have tried a number of things including setting the question field in the scorecard table to a lookup based on the following query:

SELECT tblQ1.Q1
FROM tblQ1;

This works however only as a list or combo box. I don't want the user to have to select the question. I want it to auto populate, is this possible?

View 1 Replies View Related

Automatically Populate A Date Field Based On Value Entered In Another Field

Nov 10, 2005

I need to create a New Form control for this situation:

If I enter a date into a field and the choice for another field is equal to a certain value. How can I get the date I entered to be automatically populated into another date field.

For example:

If I enter 11/10/2005 in a date field and I choose either "BN", "BA", or "BT" in a text field, I need that date of 11/10/2005 to be automatically populated in another date field on the same form.

Any help is greatly appreciated.

View 2 Replies View Related

Tables :: Auto Populating A Field Based On Selection Of Other Field

Jun 27, 2014

I (will have) a form which a user fills in to enter new data.

I have two fields,

"Branch" and "Branch ID" (Branch ID will not be on the form, just in the table)

Branch will be fed by a combo box with seven choices. I would like it so that when "Branch" is populated it autopopulates Branch ID with a code which relates to the branch, so for example

BRANCH BRANCH ID
Braintree BRA
Colchester COL

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved