Update Record If Unique Match

May 11, 2006

This is probably dead simple, but I am brain dead today.

I have two tables:
Requests with fields (ID, Cust, Amount, Ref, Date)

and

Actuals with fiels (ID, Cust, Amount, Ref, Date)

Now,
if Requests.Ref is null, then update Requests.Ref = Actuals.Ref and Requests.Date = Actuals.Date if and only if
there is only one record in Requests and only one record in Actuals where Requests.Cust = Actuals.Cust and Requests.Amount = Actuals.Amount.

Currently, I am just doing an inner join between the two tables, but if there are two requests with a given cust/Amount, but only one Actual, then both Requests will get the same Actual Ref and Date.

So how do I structure this SQL?

Thanks,
David

View Replies


ADVERTISEMENT

Modules & VBA :: Match Partial Text String And Update Record

Jun 13, 2013

I am provided a spreadsheet that contains multiple rows of similar data; each row/record represents a different stage in the process of financial transactions (requisition, purchase order, & voucher payment). Each financial transaction has these three records, with the amounts in one of three columns (pre-encumbrance, encumbrance, and expense), depending on the process.

What I am really after is the fuller, more detailed description that is apparently only available for the two records I don't want to import into the database (which is tracking only expenses and not the other two stages of the process). There is apparently no way to cross-reference these multiple rows due to the way the original database was designed (and we apparently have no control over this).

After importing the spreadsheet into Access, I would like to match the partial text string (truncated description) to the full description in another record, and update the record with the truncated description to the full description. To make mattes more complicated, I will also have to match values in the "pre-enc" or "enc" field with the "exp" field across these three records to make sure the correct descriptions are being matched because the truncated description will match multiple distinct records with the longer description.

TypeDescrPreEncEncExp
VOUJsmith-Instructor, 12/16/13$0.00$0.00$45.00
POJSmith-Instructor, 12/16/13, Course1, Parking($45.00)$0.00$0.00
REQJSmith-Instructor, 12/16/13, Course1, Parking$0.00$45.00$0.00
VOUJsmith-Instructor, 12/16/13$0.00$0.00$221.13
POJSmith-Instructor, 12/16/13, Course1, Lodging($221.13)$0.00$0.00
REQJSmith-Instructor, 12/16/13, Course1, Lodging$0.00$221.13$0.00

View 5 Replies View Related

Queries :: Update A Field If Find A Match In Another Table

Jun 29, 2015

I have a table Billing_Temp that I need one field updated if I find a match in another table Random_Temp. I runt the query and it prompts for "Enter parameter value: Random_Temp.peopleID... what could be going on? Both tables have a field called peopleID and always Billing_temp has many more records than Random_temp:

UPDATE Billing_Temp SET Billing_Temp.audited = -1
WHERE (([Billing_Temp].[peopleID]=[Random_Temp].[peopleID]));

View 1 Replies View Related

Finding A Record Where 4 Criteria Must Match

Aug 13, 2005

How do I set up a search on my form where 4 fields must match exactly to return the correct record? I must match - persons name, description, type and date.

Thanks
J

View 6 Replies View Related

Still Need Help Finding A Record Where 4 Criteria Must Match

Aug 19, 2005

--------------------------------------------------------------------------------

How do I set up a search on my form where 4 fields must match exactly to return the correct record? I must match - persons name (text), description (text), type (text) and date (date). I would always search on all four fields.

Thanks
J

View 2 Replies View Related

Forms :: SQL To Add New Record Form One Table To Match Another

Mar 3, 2014

I have a form that I need to add a new record using embedded SQL rather than just binding the form and using an automatic new record. My form will display the needed random number in a textbox and that needs to be my new record number. So I need first to check to see if that number already exists as a record number then add it if it does not and either way insert or update a set of additional fields. Something like:

DoCmd.RunSQL "SELECT * FROM tblExceptions WHERE ReconciliationID = " & Me.txtReconciliationID
Psuedocode: IF Record Exists UPDATE Field1 and FIELD2
Else Create record and insert VALUES into Field1 and FIELD2
End If

View 4 Replies View Related

General :: Match Typed Text And Forward To That Record

Oct 20, 2013

I've got an access form, and all I want to do, is to be able to type a number into a text box, click a button and then for the record containing that number to be displayed (in that same form).

-And I dunno where to start.

I don't like using the navigation bar, although that is almost what I'm after.Also, search functions I've seen on here that use combo box lists to display results seem like too much for me, as each number typed into my search box will be unique.

View 4 Replies View Related

Setting Default Values In Combo Box To Match The Value Of Previous Record

Dec 21, 2005

G'day. I've been browsing the forum trying to find a solution to a problem, without much luck, and am hoping that someone might be kind enough to help me more directly.

I'm a biologist and a newbie to access: with the distinction of being completely clueless about VBA. Nonetheless, I have been tasked with creating a database for storing data obtained from biological surveys of juvenile salmon and harvest/spawner surveys of adult salmon.

The bones of the db are in place and functional. The problem I have is streamlining the data entry process to minimise keystrokes/mouse clicks.

I have a subform for entering fish records with attributes such as 'species_name', 'fork_length', 'count', 'presence of tags, etc. The idea is that fish can be entered as individuals (count=1) or groups (count>1) with attribute data at the appropriate level (eg, fork lengths only entered for individuals. We typically measure the fork lengths of the first 20 individuals of each species and then tally the remainder).

One problem I face is that fish often occur in schools, and it becomes quite tiresome to click and select the same species_name combo box value for each record when entering multiple individuals of fish of the same species.

What I would like to do is set the default value for that combo box (on the fish subform) to match the value entered for the previous record.

I suspect that you could use the after update trigger to execute some code to change the default value each time something is entered manually into the combo box. Unfortunately, I know nothing about how to write the appropriate code.

Can anyone offer me some guidance?

Thanks in anticipation.
Sincerely,
Craig Dolphin

View 11 Replies View Related

Unable To Match If User Already Started A Record Using Date And Username

Aug 1, 2014

I am trying to match if a user has already started a record using the date and username. I have written the following code but I keep getting a error 94 about null. I know its an issue involving the date part. why this isn't working.

Code:
DLookup("TimeSheetID", "TimeSheet", "EmployeeID=" & Nz(Me.ListEmploy.Value) & " AND TimeSheetDate=#" & Date2 & "#")))
The full code

Code:

Dim Date2 As Date
Date2 = Date
If (Not IsNull(DLookup("TimeSheetID", "TimeSheet", "EmployeeID=" & Nz(Me.ListEmploy.Value) & " AND TimeSheetDate=#" & Date2 & "#"))) Then
lngEmployeeID = DLookup("TimeSheetID", "TimeSheet", "EmployeeID=" & Nz(Me.ListEmploy.Value) & " AND TimeSheetDate=#" & Date2 & "#")
DoCmd.OpenForm "frmTimeSheetMain", , , "TimeSheetID=" & Nz(lngEmployeeID), , , "NoTimeSheetID"

View 5 Replies View Related

General :: Update Record ID To Another Record ID In Same Table And Update Related Records

Aug 22, 2013

I have a table called tblCompanies. When a company acquires another company, I need a method by which the acquired company's CompanyID (PK) can be updated to the new company's CompanyID (PK). I also need to be able to update all related CompanyIDs (FKs) to the new value in related tables.

In cases in which the new company does not have an existing record, there is no problem: the company name simply gets changed to the new company and the existing CompanyID is maintained. I then use an audit table and Track Changes function to keep track of the company name data and a union query to keep the old names in the selection lists.

The problem is when both companies already have existing records in the table.

So, let's say I have records for Company A and Company B. Company A merges with Company B and Company B is now the main record. What is the best, simplest and easiest way to update the CompanyID (PK) from A to B and change the CompanyID (FK) to the new value in all related tables?

I am envisioning a pop-up form that directs the user to select the new company and then an update query happens behind the scenes... but exactly how does the criteria for the update query get selected and how do all the related tables get updated? My vba skills are pretty basic, will I need extensive coding to do something like this?

View 6 Replies View Related

Unique Record

Aug 3, 2006

I have a query which displays two fields: client ID and order type. I want to be able to display the client only once per order type. I tried to use GROUP BY order type but that gives me a missing expression message. I also thought of using UNIQUE as YES in qry properties but I'm not sure as to which row that property applies (all of them?). What is the best way to display a unique client in one row and order type in the other? So for example for order type "CASH" I wil then have a list of unique individualIDs.

thanks,
M

View 3 Replies View Related

Select Unique Record

Apr 4, 2007

I want to select unique country names from a recordset and now my code is

strSELECT = "select distinct country"

The problem is that ASIA and Asia are different, but it only selects one.How can I include both of them?

View 5 Replies View Related

Can't Save Record Changes Due To Unique Index

May 22, 2007

Hi,
I'm not sure where to post this, maybe VBA or Forms would be better, but I think it's fundamentally an index problem, so I'm posting here. I've searched both the net and here, but most of the questions are about preventing duplicate records.

I want to prevent duplicate records but save changes to existing records.

I have a form based on a table that has a 3-field-unique-index (but not the primary index, which is autonumber). I've written a function to check for existing records with the given combination of the three fields, as long as all have data (it bails if any are null). I'm calling the function from BeforeUpdate for each of the textbox controls. I was also calling it from the form's BeforeUpdate, but commented it out as it seemed redundant. I have other code there verifying that the user wants to keep the changes.

I'm trying to save the users from getting all the way to the end before discovering there's a problem. To test it, I added then deleted one character from one of the three relevant fields in an existing record, and bing, up pops my alert that I'm violating the index. Then I can't leave the field, I'm stuck there because I can't save the record.

I want it set up so that other fields in the record can be changed/updated AND so that a new record for the same person can't be entered (a dupe).

Oh, and I'm running into all kinds of problems with acCmdSaveRecord not being available. I feel like an idiot that I haven't been able to make sense of the posts about that. I can just comment it out and let Access save the record when it closes the form. But my bosses really want the users prompted about saving changes.

Any thoughts or suggestions or insights greatly appreciated. I really tried to search this out, so any tips for better searching are also appreciated.

Here's the code for the function:

Public Function CheckForClientDupes()
Dim response As Variant
Dim strFamID, strLName, strFName As String
Dim strFilter As String

If IsNull(Me!FamilyIDNo) Or IsNull(Me!strLastName) Or IsNull(Me!strFirstName) Then
Exit Function
End If

strFilter = "[strFamilyIDNo] = """ & Me!FamilyIDNo & """ And " & "[strLastName] = """ & Me!strLastName & """ And " & "[strFirstName] = """ & Me!strFirstName & """"

If DCount("*", "tblClients", strFilter) > 0 Then

response = MsgBox("There is already a client with this combination of FamilyID, Last and First names in this database. Would you like to Continue Anyway (Yes) or cancel data entry and Erase Your Changes (No)?", vbYesNo, "Duplicate Client Alert")
If response = vbYes Then
' DoCmd.RunCommand acCmdSaveRecord
Else
response = MsgBox("You have chosen to cancel your changes. Your changes will be erased.", vbOKCancel + vbQuestion, "Data Entry Cancelled")
If response = vbOK Then
Me.Undo
Else
Exit Function
End If
End If
End If

' Me.FamilyIDNo.SetFocus

End Function

View 3 Replies View Related

Combo The Unique Id To Search A Record

Nov 23, 2006

Is it possible to create a combo box to list all record ID, when selected that record appears on the form?Ifso how would i go about this?

Thanks in advance?

Andrew

View 1 Replies View Related

Queries :: Extract One Record Per Unique ID

Feb 19, 2015

I have a table like so:

Code:
PatientID VisitDate Complaint TestPos
1 4/5/2003 Coughing 1
1 1/2/2007 Sneezing
1 5/1/2008 Unknown 1
2 2/1/1988 Unknown
2 4/2/1988 Unknown 1

I'd like to extract just one TestPos record (TestPos = 1) per Patient ID. And I always want to select the record with the earliest date. So the result would be:

Code:
PatientID VisitDate Complaint TestPos
1 4/5/2003 Coughing 1
2 4/2/1988 Unknown 1

I can do this but it requires 3 queries: a SELECT query where TestPos = 1, a GROUP BY PatientID query and MIN(VisitDate) to get the desired record per patient, and then another query that links the two so I can get the additional variables (e.g., Complaint).

Is there a way to do this without using 3 queries? Seems inefficient.

View 3 Replies View Related

Problems Making A Field In A Record With A Unique Value

Oct 23, 2004

Hi I have a very simple table, with say 5 fields (all text). There is only 1 table. The first field is name, and I want to enforce its uniqness across all other table.name values. I am completely new to Access database and am not sure how to do this.
Any help would be greatly appreciated.

Thanks, Edin

View 3 Replies View Related

Queries :: Unique Record Table Query

Oct 22, 2013

I am using a software drawing program that intelligently link information from a drawing to a database and vice versa. I have many tables and queries that I have created over time that enable auto populating of tables, creation of tables and so on. All of which enable me with tabular documents for ordering purposes.

The problem I currently have is: - I want to create a table that looks at an existing table, analysis various fields for duplicate information and then adds one record to a new table. This is to enable me to create a spares list based on the entire list.

I have a full valve list with various items, some duplicates some not. I am required to produce a spares list that considers only one of each type.

View 10 Replies View Related

Assign A Unique Two Letter Code To A Set Of Record?

May 23, 2012

I am trying to assign a unique two letter code to a set of record. From AA..AB..BA....all the way to ...ZZ, how do i go about doing this ?

View 14 Replies View Related

Unique Number To Identify Each New Record Created

Sep 23, 2011

Example 1:

2011-1
.......
2011-3893 etc.

Currently I have an Access form which produces a new unique number to identify each new record created. To do this I use the unique ID autonumber from a table to identify the new records. I would like to change from this simple number to the the above format per example 1. The four digits to the left of the hyphen would always be the current year and digits to the right of the hyphen would be the unique auto incrementing numbers such as from my table. I need the year to auto increment by 1 each September 30th (new business year) and I need the numbers to the right to auto reset to 1 to start uniquely identifying records again for the new incremented year. As each record is closed I need the number to be written as a single entity in the new format to my database.

Example 2: After September 30th.

2012-1
.......
2012-447 etc.

View 3 Replies View Related

Unique Identifier - Append Primary Key Record

Dec 9, 2014

I have a database in Excel that contains farmers who can be identified by a Unique identifier: MZ-01-0001. The registration details for these farmers are not always up to date. Now when I try to append the data for the farmer with MZ-01-0001; with the primary key set on the Unique identifier, Access does not want to do it since there is already a record in the system. When I remove the primary key it doubles the record, which is also not what I want. So I am wondering what I need to do to append the record while keeping the primary key intact.

View 4 Replies View Related

Finding Sequence Of Fields Making A Unique Record

Aug 23, 2006

I have a MS Access 2000 database with 136 data tables in it. What I would like to do is execute a piece of VBA code which will list for me in another table, (for example: Field1: TABLE NAME Field2: FIELD NAME 1 Field2: FIELD NAME2 etc), starting left to right, how many fields would have to be combined in each table to represent a unique record.

For instance:

TYPE ID TEXT
1 1 "Cats"
1 2 "Dogs"
2 1 "Rabbits"

In this example a combination of the fields TYPE and ID give a unique record.

Any help most appreciated.

Dalien51

View 1 Replies View Related

Reports :: Table With Data - Unique Part Of A Record

May 28, 2013

I have a table with data like this

Field_1,Field_2,Field_3
A,B,5
A,B,3
A,C,7
A,C,6
X,Y,4
X,Y,3

I need a report where I can only see

A,B,5
A,C,7
X,Y,4

That is Group by Field_1 and only show the records which has Field_2 with the max. value of Field_3

View 1 Replies View Related

Queries :: Merge Unique Data With Same Persons Record

Jun 14, 2013

As mentioned before on a different topic I am building a database to sort through publication authors. I currently have the table sorted in a way that only the main author is listed for the 3000 records. Now I need a way to remove duplicate entries on a new table. Each entry is a different publication. Each record has a DOI code that is unique and an author which might be a duplicate. I want a new table listed by author once and a new field that list all of the DOI numbers for that author.

I know how to do a query to show only the unique names, but how to I also get the database to combine the records that share the same author.?

View 7 Replies View Related

Tables :: Unique Record Entry - Index Or Primary Key Cannot Contain A Null Value

Dec 6, 2012

I am building a database to capture monthly statistics on a number of items. I want to ensure that users don't enter statistics for the same item for the same reporting period. I found the following instruction, but can't make it work:

It suggests that I create multiple primary keys in the table

When I do it, it comes back with an error: Index or primary key cannot contain a null value.

View 6 Replies View Related

Forms :: Generate A Unique Reference Number Record Wise

Jun 10, 2015

Need to generate a unique reference number each record wise while data entering by a form. How to do this by using a command button ? After entering all fields related to the record, when click on the command button, unique reference number for that record need to be generated and save with all other data of the records. in a later event, need to recall the record by using this reference number and also need to make relation ship with some other table by using the reference number.

View 6 Replies View Related

Tables :: Run Lookup With Unique Criteria Based Off Each Individual Record

Aug 31, 2013

I want the lookup to be performed with criteria based off of the same row that record being selected is on.

I wrote typed out the Columns and rows that my queries return, and attached a screenshot as well.

You enter your phone number which provides you with an indexed location. Based off of that location only certain products are available and I want them to be filtered accordingly. I have it working to some extent, here is an example below:

|Site Name|Phone Number| Location |Products Available|
| Store 1 | 5044645521| KNNRLABR

The lookup displays products available where the indexed products match the same location. Here is what the query returns:

| Location |Products Available|
| KNNRLABR| Product 21 |
| KNNRLABR| Product 9|
| KNNRLABR| Product 7 |
| KNNRLABR| Product 3 |

This is the affect that I want to achieve but, if I add another location like so:

|Site Name|Phone Number| Location |Products Available|
| Store 1 | 5044645521 | KNNRLABR |
| Store 2 | 3609061624 | VANCWA01|

The lookup returns all products available for all the records for each location entered rather than based off of the selected record.

| Location |Products Available|
| KNNRLABR | Product 21 |
| KNNRLABR | Product 9 |
| KNNRLABR | Product 7 |
| KNNRLABR | Product 3 |
| VANCWA 01 | Product 31 |
| VANCWA 01 | Product 8 |
| VANCWA 01 | Product 4 |
| VANCWA 01 | Product 3 |
| VANCWA 01 | Product 1 |

Is there a way I can make the lookup run off of the location specific to the current row that I am working on?

P.S. Here is a copy of the SQL statement I'm using right now.

SELECT DISTINCTROW [DSL Product CLLI's].CLLI, [DSL Product CLLI's].Speed, [DSL Product CLLI's].CLLI
FROM [DSL Product CLLI's], [Copy Of Copy Of Customer NPA-NXX's - ADSL - Data - Internet]
WHERE ((([DSL Product CLLI's].CLLI) In (SELECT DISTINCTROW [Location] FROM [Copy Of Copy Of Customer NPA-NXX's - ADSL - Data - Internet] WHERE [Copy Of Copy Of Customer NPA-NXX's - ADSL - Data - Internet].[Location]=[DSL Product CLLI's].[CLLI])));

Which Returns the Following in my lookup field for Products Available.

View 6 Replies View Related







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