473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Link one field to a field in another table (linked from another DB) if the Drop = A

I have a DB table that is linked to my new DB. I can't edited the linked table. So I created another DB w/ additional data however I still need to pull data over from one to the other.

My DB has 2 fields
A: Action Type (this is a dropdown)and B: Action Date.
I need to pull the Action Date over to the linked table "Delay Date" if the Action Type = Delayed.

Also if I could get a 3rd field "Reason" to be filted by what is selected from Actiont Type. That would be great. Thank you!
Sep 9 '10 #1

✓ answered by NeoPa

If there are multiple possible versions of these records then you will need to decide how to determine which to use.

This SQL should work for taking the last date found in the sequence of the records as they come. NB. This is not the same as coming in date sequence necessarily. If there is only one of each then you shouldn't have the problem. Try it out and see how you get on with it :
Expand|Select|Wrap|Line Numbers
  1. UPDATE [Table A] AS tA
  2.        INNER JOIN
  3.        [Table B] AS tB
  4.     ON tA.SSN = tB.SSN
  5.  
  6. SET    tA.[Intake Delay Date] = IIf(tB.[Action Type] = 'Delayed'
  7.                                   , tB.[Action Date]
  8.                                   , tA.[Intake Delay Date])
  9.      , tA.[Intake Completed] = IIf(tB.[Action Type] = 'Done'
  10.                                  , tB.[Action Date]
  11.                                  , tA.[Intake Completed])
  12.  
  13. WHERE  (tB.[Action Type] In('Delayed', 'Done'))

23 2789
NeoPa
32,556 Expert Mod 16PB
Susan, I'm afraid it isn't very clear what you are hoping to achieve. Are you looking for linked data to be displayed on a form or for existing data from the old DB to be used to populate your new one?

In either case some basic information about the fields (and/or controls) involved would be useful.

Welcome to Bytes!
Sep 10 '10 #2
I need to take the Action Date from my sub form "Intake" and place it in the Intake Delay field in the Master form "Main DB" the issue is that the Action Type (from the sub form sets the criteria.
If I select "Delayed" for the Action Type and put a date in the Action Date I need that date to link to the Intake Delayed field in th master form.

I hope I helped explain it. Thank you!
Sep 10 '10 #3
table A (master)
table B (sub)
field A.1 (Intake Delay Date)
field A.2 (Intake Completed)
field B.1 (Action Type--this is a Dropdown)
field B.2 (Action date)

IF B.1= "Delayed" then B.2 will link to A.1

I also have to have IF B.1= "Done" then A.l is blank and B.2 (only for Done action) is linked to A.2
Sep 10 '10 #4
NeoPa
32,556 Expert Mod 16PB
A simple answer to my questions would have been preferable. It's very hard to work with multiple versions of the explanation, all with differences. I'll do what I can though, as I'm sure you were trying to be helpful.

I must say that as what you're suggesting doesn't make a whole lot of sense in a database context, I'm finding it hard to guess exactly what you are looking for. Calculating a value to display is one thing, but saving that away automatically is another different thing entirely.

That first question really was quite important. It gives me a clearer understanding of what you might be expecting. Retrospectively updating all your internal (new DB) data from the external data is one possible approach, or simply linking in to the external data using a query is another. Unfortunately, your descriptions so far seem to include a bit of both. Hence the question, the answer to which could have told me what your experience doesn't allow you to yet. Does that make sense?
Sep 10 '10 #5
No I need linked data from the new table to be linkeed to the old table. The old table is a company table (i.e. Master or Table A) and the new one in our groups data (i.e. Sub table or Table B.

Basic Field data:
Table A (company/ Master)has many text field w/ mask inputs for dates but I am looking mostly at just 2 of them. The "Intake Delay" and the "Intake Completed".

Table B (our group/ Sub)has only 4 fields "ID Auto Number", "Action Type" (this is the dropdown that is linked to another table for the list) and "Action Date" (this is a date/time field w/ an input masks.

The tables have a relationship by SSN.

Part 1: Can I get our "Action Date" field to copy/link to the companies "Intake Delayed" if our "Action Type" is selected as "Delayed"?

Part 2: If there is an "Action Type" that is selected as "Completed" for the same person it will remove the "Intake Delay" date from the companies table?
Sep 13 '10 #6
NeoPa
32,556 Expert Mod 16PB
Everything you say is detailed, but I am struggling even to grasp the concept of what you're trying to ask. Detail, in the circumstances, is of no help whatsoever at this stage.

Why don't you let me lead and you just answer the questions asked. It really will be much easier that way. I'm assuming you need my help. I can only give you help when I understand your problem clearly. At this time I'm still not in that position as you haven't answered my question (which I'll reapeat here for clarity). It's not a question that can take a yes or no answer. The answer must be A or B.
Are you looking for :
  1. Linked data to be displayed on a form?
  2. Existing data from the old DB to be used to populate your new DB?

The solution will be markedly different depending on the answer to this simple question. It will make more of a difference than all the other details.
Sep 15 '10 #7
B , but it is the data on the new one to populate to the old
Sep 15 '10 #8
NeoPa
32,556 Expert Mod 16PB
Good. A surprise, but clear.

I was out all evening tonight but I haven't given up on this. I'll have another look tomorrow.
Sep 16 '10 #9
NeoPa
32,556 Expert Mod 16PB
I've started to look at this again Susan from the new perspective. I was reading the OP (Original Post) when I noticed that you're unable to edit the linked table. I'm a bit confused by this. If you have no write access to this linked table, why are we talking about updating this table with data from the new (local) one?
Sep 16 '10 #10
Data entry is fine to add in to old table but because other groups use the old one as well I can't revamp it all.
Sep 16 '10 #11
colintis
255 100+
Susan, can you actually get into the source database where your link table is from? or why not group the additional data in another table, and a column reference that linked table's primary key? Then create a query to acts like a joined table.
Sep 17 '10 #12
NeoPa
32,556 Expert Mod 16PB
Ah. The design cannot be edited but the data can. That's good to know.

I now know enough to know that we should be looking at running an UPDATE query to update the original table from your new one in the new database. I will look through your earlier posts again as I suspect much of what I need is already there. If I find something missing that I need I'll post to ask for it.

By the way, just to give a bit of background, had the answer been A then we would have been looking to work within VBA on a form. A different approach entirely.
Sep 17 '10 #13
NeoPa
32,556 Expert Mod 16PB
I need to ask how the two tables are linked. There is something in post #6 about SSN, but There are no fields called SSN described anywhere, and nothing to indicate what type of relationship exists between them.

If I were guessing I'd say :
Table A (master - Table in original database)
Field A.0 (SSN)
Field A.1 (Intake Delay Date)
Field A.2 (Intake Completed)
Table B (sub - Table in new/local database)
Field B.0 (SSN)
Field B.1 (Action Type--this is a Dropdown)
Field B.2 (Action date)
and that [Table A] and [Table B] are linked in a one-to-one relationship such that each record in [Table A] has one, and only one, matching record in [Table B].
Sep 17 '10 #14
Yes the lay out is correct, however it is a one-many relationship. If I pull up 000-00-0009 Jane Doe then i get both the basic info from the Table A and a running list of Jane's action from Table B (linked by SSN)but some of the basic info Table A is the same as mine Table B. i.e. Delayed and Intake Complete
Sep 17 '10 #15
Can I link the "Action Date" form Table B to Table A "Intake Delay Date" if the "Action Type" from Table B = Delayed
Samething like this:
Link [Action Log].[Action Date]TO [Company].[Intake Delayed Date]If [Action Log].[Action Type]= "Delayed"


P.S. I know this is a poor code but maybe it will help explain.
Sep 17 '10 #16
NeoPa
32,556 Expert Mod 16PB
Susan, all of your explanations make proper sense only when assuming a one-to-one link. Nowhere does any of your posts allow for multiple records to be taken into consideration.

Please try to explain precisely what updates you require in a way that makes clear how to handle all possible scenarios. For instance where there are many matching records and more than one where the [Action Type] is "Delayed" as well as more than one where the [Action Type] is "Completed". If any of these are not possible due to constrictions on your data, then of course we need to know that too.
Sep 20 '10 #17
Great Question! As far as I know there should be only one action type that = Delayed and only one action type that = Complete per person.
However lets go w/ the later (more than one action type that states Delayed and more that one that state Complete). Just in case it comes about later. What do you think would be the best cour of action to provent this from happening? FYI I can only have 1 personnel entry (on the Master DB- Table A).
Sep 20 '10 #18
colintis
255 100+
Gosh...I wish I'm sitting right in front of you so we can make discussion with pen and paper(maybe easier to understand).

Anyway, is the "Action Date" form Table B has any other targets that would link to besides the Table A "Intake Delay Date"? If not, you can still make the link, only we make some codings to take some actions if "Action Type" from Table B = Delayed or not.
Sep 20 '10 #19
The Action Date in Table B will also need to link or update (what ever I have to use or call it to get it to work) to other fields in Table A. All links must be based on what the Action Type is (i.e. you select Delayed for the action type in table B then Intake Delayed date in Table A will get the same date as table B for that action) Same goes for Complete, and New.



Table A.....................Table B
SSN (PK)...................SSN (PK and Relationship)
Name
File Received Date= 9/01/2010 ......... Action Type=New File and Action Date= 9/01/2010
Delayed Date= 9/05/2010............... Action Type=Delayed and Action Date= 09/05/2010
Completed Date= 09/10/2010..........Action Type= Complete and Action Date= 09/10/2010

Table A needs to get their dates from table B if the action type matches the criteria.


I hope this helps explain. I real don't know how to any more and I am sure once worked out I will kick my self for not getting it. :)
Sep 30 '10 #20
colintis
255 100+
So from table A, you want to combine 2 fields into one?
E.g. If Action Type = "New File", and Action Date = "9/1/2010". Then you store these 2 data into 1 field as "File Received Date = 9/1/2010"?
Oct 1 '10 #21
NeoPa
32,556 Expert Mod 16PB
Sorry I've left this hanging somewhat. I haven't had much time recently to devote to the site (See NeoPa Absence).

I am trying to catch up with all my outstanding threads (I have quite a few so this may take some time).
Oct 1 '10 #22
I can't access the link you posted, but from the title I don't think I need to.
I only have until the 19 Oct. 2010 to get this set up and would realy like to give a completed database to my boss at that point (seeing as I am the only one with a clue on how to set one up). I would be greatful for any information that I can complete this task. Thank you.
Oct 4 '10 #23
NeoPa
32,556 Expert Mod 16PB
If there are multiple possible versions of these records then you will need to decide how to determine which to use.

This SQL should work for taking the last date found in the sequence of the records as they come. NB. This is not the same as coming in date sequence necessarily. If there is only one of each then you shouldn't have the problem. Try it out and see how you get on with it :
Expand|Select|Wrap|Line Numbers
  1. UPDATE [Table A] AS tA
  2.        INNER JOIN
  3.        [Table B] AS tB
  4.     ON tA.SSN = tB.SSN
  5.  
  6. SET    tA.[Intake Delay Date] = IIf(tB.[Action Type] = 'Delayed'
  7.                                   , tB.[Action Date]
  8.                                   , tA.[Intake Delay Date])
  9.      , tA.[Intake Completed] = IIf(tB.[Action Type] = 'Done'
  10.                                  , tB.[Action Date]
  11.                                  , tA.[Intake Completed])
  12.  
  13. WHERE  (tB.[Action Type] In('Delayed', 'Done'))
Oct 4 '10 #24

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: MichaelJohnson168 | last post by:
I am trying to grab the UnitPrice from Table 1 and store it in the UnitPrice field in Table 2 whereever there is a match ProductID wise. Table 1 - ProductID, ProductName, UnitPrice Table 2 ...
6
by: leodrums | last post by:
I have to tables with different names, and I need to insert into the destination table a field from the origin table that has the same name as the field in the destination table.
1
by: lcourchesne | last post by:
Hi there, This is what I am trying to do: Create a query that will insert a column from Table 2 into Table 1. These two tables are exactly the same in structure, however, there is no unique...
3
by: webcat | last post by:
Hi I need to UPDATE data into a table mainData which contains many fields - one is CODE and one is DESCRIPTION another table DESCRIP is a lookup - it also contains the same fields, but...
2
by: VooDoo | last post by:
Hi, i am trying to copy a completed field set from one table to another. I am using this SQL command: INSERT INTO doc_valid SELECT * from doc_temp where id=$id it works, but it also copy the...
2
by: JC21 | last post by:
Hi All, I would like to know how do I compare one field in one table to another in another table. I have one table which is the Archive table. It keeps a history of everything, I have another...
2
rightclick
by: rightclick | last post by:
I am setting up a database to be used to keep a point ranking system for my table tennis school. I have a table tblMain with records for each player. It includes a field called StartOfSeasonRank....
2
by: jaad | last post by:
Ok I am seriously starting to scare myself with this one. I've only been dealing with Access 2007 since August of 2009 and being a newbee I made a lot of mistakes but learned a lot since then. My...
4
sueb
by: sueb | last post by:
I'm not sure how this happened, but the current version of a table in my database has lost all the values in one field. The previous backup has the correct values. How do I copy the correct...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.