Modules & VBA :: Update Table Field Based On A Query

Nov 16, 2013

I have a table 'table1' which has various field including an ID field and a yes/no field. I then have a form based on a query originally derived from data in the original table. The form provides a list with some ID's with a yes and some with a no.

I'm trying to write a button code to convert all the no's into yes' for those ID's picked out by the query.

I've searched lots of sites and get that I need to set recordsets for both table1 and the forms' query but all my efforts crash or give an error.

I am looking for the right way to say .." for each ID in form set the yes/no field corresponding to the same ID in table1 to yes"

I'd attach my version ....

View Replies


ADVERTISEMENT

Tables :: Update A Field In One Table Based On Status Of A Field In Another Table

Aug 2, 2013

I have started work on a database to track the many (several hundred per annum) projects my company undertakes. A 'main' table lists projects, their fees, their key dates, their project numbers, etc. I have created another table for tasks. Each task is assigned to a project (via the project number), and may be 'open' or 'closed'. I have separated the tasks table from the projects table as there may be several different tasks for each project. It is also good to keep a record of the tasks.

I want to prepare a report from the projects table that lists projects IF they have any open tasks.

In my mind, this means 'If a task, with the corresponding project number, is open, put a 'Yes' in the 'Tasks open' field of the Projects table.'

View 7 Replies View Related

Update OnHandQty Table Field Based On Qty Field From Another Table / Form

Oct 30, 2012

I have a table called Inventory (table1 - PK=INVID) that contains all inventory ID numbers and descriptions. I have another table called Inventory Transactions (table2 - FK=INVID) that gets updated through a form. When a new transaction is made in table2, I want the transaction amount to get added or subtracted to an OnHandQty field in table1. I tried having table2 (transaction table) as the main form and then table2 as the subform, but I couldn't get table2 to update.

View 5 Replies View Related

Modules & VBA :: Update Field Value Based On Another Field

May 11, 2015

I have the following fields in an A2010 form

PaymentMethod
Total
InstalmentAmounts
OurFee

InstalmentAmounts field is populated based on the results of PaymentMethod which is a combo box

Here is the current code

Select Case Me.Payment_Method.Value
Case "Three post dated Cheques"
'If three payments by cheque
Me.InstalmentAmounts.Value = Round(Me.Total.Value / 3, 2)

In some cases there will be a few pennies that the client "overpays" because the instalment amounts will not add up to the Total. I need to add up the TotalInstalmentPayments to find out what the client actually pays and then add the difference between TotalInstalmentPayments and Total to the OurFee field

So

Total = 500.00
Payment Method = 3 instalments so
IstalmentAmounts = 166.67 (rounded) so client pays 500.01 so the 0.01 needs to add to the OurFee field.

View 4 Replies View Related

Trying To Update Field Based On Other Table

Jul 25, 2006

I have the following situation.
Table 1:
------------------------
Primary Key
Name
Secondary key

Table 2:
------------------------
Primary Key
Age
Secondary Key

*****************************
This is just an example. The first table is totally populated. The second table does not have the secondary key assigned, but otherwise is populated. In additon, some of the records in Table 2 do not have a matching entry in table 2.
I would like to be able to update table2, populating the Secondary Key field in order to allow me to delete the Primary Key fields. The Primary key was assigned by somone else who created the db, and makes no logical sense, i'm trying to replace it with a key that can be used more easily. Any help would be greatly appreciated.

Kevin S. Jones

View 1 Replies View Related

Modules & VBA :: Update Column In Table Based On Another Table

Apr 24, 2015

I'm trying to use VBA to update a new column in a table with info I already have in another table.The table I want to update is an inventory details table, it has around 25,000 records. I added a column called "UnitCost", of course the column is empty for all 25,000 records so I would like to fill it easily using DoCmd.RunSQL "UPDATE" feature.

I use that through-out the program however I'm unable to connect the dots for this one.What it needs to do is update "UnitCost" in "InventoryDetails" from "Products" where "InventoryDetails.ProductNumber" = "Products.ProductNumber"

The "Products" table has all the different unit cost, it just need to be placed in the "InventoryDetails" table for every record. Of course product1 needs products1 unit cost and product2 needs products2 unit cost, etc.

View 1 Replies View Related

Update Field Based On A Reference Table

Mar 15, 2006

I would like to update two fields [Category] and [ProdType] in tblAccum based on a reference table.

The reference table is tblReference and contains the fields [Code], [Category] and [ProdType].

tblReference example of field values:

Code Category ProdType
A Blank Accessory
BS Blank Blank Stock
O Printed Offset

So if the Code field in tblAccum has a value of O then based on the tblReference table the Category value would be Printed and the ProdType value would be Offset.

Any help is greatly appreciated.



Thanks,

View 7 Replies View Related

Modules & VBA :: Update A Table With Dates Based On User Input

Dec 30, 2014

I am new to VBA and I'm trying to write a query that will update a table with dates based on user input. For example a user will run data each Monday and that date will be day01. The date table has 28 days total and I need each day row to update with the next date i.e. day01 is 12/30, day02 is 12/31, day03 is 1/01 etc..I am having issues just running the update the query. I get a too few parameters error message on the strsql statement. There are only two columns in the table, order_day(date column) and date_value(text). I want to update order_day. I also need creating a loop so it knows to go back and add days to the other values.

Here is what I have:

Code:
Sub Update_Dates()
Dim rs As Recordset
Dim db As Database
Dim lmsg As String
Dim transactiondate As Date
Dim strsql As String

[Code] ....

View 6 Replies View Related

Modules & VBA :: Update Recordset Based On Max Process Instance From Another Table

Jun 7, 2013

I am trying to update a recordset using VBA based on the max "process instance" from another table. After the code executes, the field I am updating is still blank.

Code:
Set rs = db.OpenRecordset("myTable", dbOpenDynaset)
If Not (rs.BOF And rs.EOF) Then
rs.MoveFirst
Do Until rs.EOF = True
emplid = rs![Employee Number]

[Code] ....

View 5 Replies View Related

Tables :: Update Table Based On Concatenated Field

Aug 8, 2013

I have a field in a table that is to be concatenated from two other fields, PolPrefix and PolNum. On a form I got it to show the full field 'PolicyNumber' by making the control source =[PolPrefix] & [PolNum].

But this doesn't update the field PolicyNumber in the respective table, and only shows it on the form. How do I get a concatenated field defined by the user into a table so that I can call that field other places in the database?

View 3 Replies View Related

Update Table Field Based On Another Field.

Mar 3, 2008

Ok. I've got a table named SIPATable and some of the fields contain summed values. Let's say for instance I have a field named "GaDRaw", which represents a raw score. now...I need to update a field called "GaDPer", based upon the value in "GaDRaw". So...If "GaDRaw" <=16, then I would want "GaDPer" to be updated to = 35. Further, if "GaDRaw" = 17. then I want "GaDPer" to = 37. and so on....

I think it's an If Then Else statement, but not sure how or where to place it. Id like it to be as code under a command button, and update the table all at once.
Any help would be appreciated.
Thanks in advance,
Freud52

View 7 Replies View Related

Modules & VBA :: Update Table Based On List Box Multi Selected Records

Nov 24, 2014

I have database with an userform called AssignWP, combobox called WPDevBy, listbox called List352 (Multi select) and table called Justified.I am trying to update one field WPDevelopedBy of the table as combobox value based on list box multi selected records.

View 2 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

General :: Automatically Update Field Based On Entry In Another Table

Jan 14, 2013

I have two tables, one called 'Company' and one called 'Person'. Both tables have several fields, but they both have the same primary key, i.e. 'Naam'.

When I type in a name in the 'Person' table, I'd like the 'Company' table to automatically display the name too. So for example if I type in 'John Doe' in the person table, I want to be able to switch to the 'Company' table and have the same name displayed there, automatically.

View 1 Replies View Related

Update Query Based On Length Of Value In Field

Jul 12, 2007

I want to create an query that will update a field value for records where the length of the field value is less than a given number (if LEN of UniqueID is less than 6 for example), but I can't figure out how to write a SELECT query, much less an UPDATE query for this condition....can someone help me, please?

View 1 Replies View Related

Can You Update A Table Value Based On Query?

Apr 27, 2006

Hi all,

Simple question...I think. Is it possible to update values in a table, based on the results of a query?

For example, I have tblPRR and qryProcessed.

When I run qryProcessed, I would like the field "Status" in 'tblPRR' to update from 'No' to 'Yes'.

Could anyone advise if this is possible?

Cheers

Rob

View 2 Replies View Related

**update A Table With A Resut Based On Query

Aug 28, 2007

Dear All,

This is my first post in the forum and would like to apologise for any shortcomings.

I want to update a field in my table with the result from a query.

Eg. Table A with two fields, a1 (recorda1) & a2 (recorda2)

Result from Query (recordq) has to be replaced in Table A, field a2.

after the code is run, (recorda2) should be replaced by (recordq)

Can anyone help me how to do this with the help of an update query.

Regards to all

Basheer

View 4 Replies View Related

Update Query Based On A Separate Table

Nov 24, 2005

Hi all,

This is quite a basic question and I'm sure that it has been posted here some time ago, although I couldn't find it on using the search.

I want to update a field in one table "FieldA" using an update query. I want the update to be based on matching Field B in the updated table, and Field C in a separate table (both tables have the same design structure).

That is, I'd like my query to search each record in the Destination Table to see if its Field B matches a Field C in a separate Table. If there is a match, I'd like to Update Field A to the corresponding field A of the reference table.

I have tried to do this with an Update Query based on both Tables in design view. Thus far, it hasn't yielded any results.

Can someone please post the solution asap. Thanks so much for your help.

Regards,

Mike J.

View 4 Replies View Related

Modules & VBA :: Updating A Field In A Form Based On Another Table Field

Sep 13, 2013

Using Access 2010. Fairly new to automation and macros.I have two tables (tblProductReceived and tblBins) and a form (frmProductReceived).A field in tblBins corresponds to a location the bin is at (named BinLocationID) and the tblProductReceived table tracks product that a specific bin has received.

What I need is for the tblProductReceived field PRLocationID ([tblProductReceived].[PRLocationID]) to be automatically populated with where the bin is at ([tblBins].[BinLocationID]) when selecting a specific bin in the form (frmProductReceived).

View 1 Replies View Related

Queries :: Update Table Query Populate Cells Based On IIF Statement?

May 6, 2013

I would like to have a table update query populate cells in a field, based on an IIf statement (below), but states that the IIf statement arguments still need to be enclosed in parentheses. I don't understand what the problem is, I have two sets of opening / closing parentheses.

Code:
IIf IsNull (=Mid( [CONTRACTOR_TASK]![TASK_NAME] ,6,6))

View 3 Replies View Related

Modules & VBA :: Update Specific Record In Table Using Unbound Field On Form

Dec 4, 2013

How to do an UPDATE using VBA on a form to update a specific record on the table using an unbound field on the form to filter the update.

Every time the code runs, it tells me: Run-time error '3144': Syntax error in UPDATE statement and takes me to the "CurrentDb.Execute strSQL, dbFailOnError" line at the end of my sample below.

Here's my code:

Dim strSQL As String
Dim strCriteria As String
strSQL = ""
strSQL = strSQL & " UPDATE [tblTicket] SET"
strSQL = strSQL & " ([UpdatedBy], [AssignedTo], [Requestor], [Dept])"
strSQL = strSQL & " Values"
strSQL = strSQL & " ('" & unbEnteredBy & "','" & cmbAssignedTo & "','" & cmbRequestor & "','" & cmbDepartment & "')"
strSQL = strSQL & "Where [tblTicket]![DateTimeOpened] = #" & FORMS!frmTicketTracker.unbDateTimeOpened & "#;"
CurrentDb.Execute strSQL, dbFailOnError

View 9 Replies View Related

Modules & VBA :: SQL Query Field Based On A String From Input Box

Sep 10, 2013

How do I use a update sql query to update a field based on a string from an input box. Heres what i have been trying:

Code:

Dim NETWORKBOX As String
NETWORKBOX = InputBox("NETWORK TO IMPORT" & Chr(10) & "EXAMPLE: PRIMARY", "NETOWRK TYPE")
sql = "UPDATE " & TABLENAME & " SET NETWORK = " & NETWORKBOX & " ;"
DoCmd.RunSQL sql

If i run the code and input 'PRIMARY' in the NETWORKBOX the sql query will return an 'enter parameter value dialog box' with the word 'PRIMARY' above the input field.

View 1 Replies View Related

Modules & VBA :: SQL Update Query To Set A Record Field To Null?

Jul 11, 2013

On a push of a button from a form, I want to locate specific records within the table and update a field to Null if it matches a name

Dim strSQL As String
strSQL = "UPDATE tblmaster SET Score = "" WHERE [AdvocateName] = 'Anna Maria'"
DoCmd.RunSQL (strSQL)

I'm certain I don't have the syntax correct between the Set to Null and WHERE clauses..

View 4 Replies View Related

Modules & VBA :: How To Make Particular Text Field BOLD Based On Value From Query

Jul 20, 2015

I am using MS Access 2007 and have a report which display the list of values (say 10 fields) from the basic SELECT * FROM table query.

I need to dynamically set the BOLD based on the particular value for the fifth field which was assigned from Query. if it doesn't match it should display normal.

E.g
If Field_5 = "Agent" then
Field_5.FontBold = True
Else
Field_5.FontBold = False
End if

I tried the aforementioned code and it dont work. ALso i tried achieve it using below listed options.

Me.Field_5.FontBold = True
Field_5.Properties("fontweight") = 700

But nothing worked.

View 5 Replies View Related

Modules & VBA :: Conversion Table And Update Query

Dec 4, 2014

I am building an access database to manage a data conversion from multiple legacy systems (62) to a new non access database, and plan on making my Conversion Database reusable and functionally simpler.All data is imported to one common Table structure, with the source system identified against each record.In my legacy systems values are not coded the same ie

Title: Mr Miss Ms Mrs Record Type: Active, Inactive
System A: 1, 2, 3, 4 a , i
System B: a, b, c, d 1 , 2
System C: x, y, z, w ACT, ,INA

This applies to sooo many fields.I want to avoid having a mapping table for each field as I will quickly have an unmanageable number of mapping tables, and complex relationships in Queries..I would like to get to the point where I could have a single value mapping table something as follows

System, Field, Old Value, New Value
System A, title, 1 Mr
System A, title, 2 Miss
System A, title, 3 Ms
System A, title, 4 Mrs
System B, title, a Mr
System B, title, b Miss
System B, title, c Ms
System B, title, d Mrs

And some how call this in VB to go through all fields and records in a table if Old Value is found for a specific "System" and "Field" Change to new value, if noting found on Mapping table keep existing data.

View 3 Replies View Related

Update Table From Query Field

Apr 3, 2006

I have a query that does calculations in the expression builder field. Is it possible to update/populate a field in a table with the calculated field/answer from the query? Thank you.

Jimmy

View 1 Replies View Related







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