compare two columns and return result from third one (1 Viewer)

sparky23

New member
Local time
Today, 21:00
Joined
Feb 18, 2019
Messages
5
Hi,

I'm trying to make small but I'm stuck here :banghead:

I need some kind of solutions in Access that will search through table and give me back a value.
In attached picture there are 3 columns.
when I give two variables exp (AA2) and (AA1), Access should find the row in the table where AA1 and AA2 are stored and
give me back the value from the third column (in this scenario 0.6).

Note that variable should be text
and the row for with AA1 and AA2 is unique. There is no AA2 and AA1 row.
So the solution should actually compare both columns with both variables.

I'm not allowed to attache the pictures so here is a short sketch:

AA1 | AA2 | 0.6
AA1 | AA3 | 1.2
AA1 | AA4 | 1.9
AA2 | AA3 | 0.6
AA2 | AA3 | 1.4
and so on

Thanks in advance

Sparky23
 

isladogs

MVP / VIP
Local time
Today, 20:00
Joined
Jan 14, 2017
Messages
18,209
Welcome to the forum.
Your post was moderated which is why it didn't appear at first.
It does sometimes happen for new members

You can attach images if you zip them first
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:00
Joined
Aug 30, 2003
Messages
36,124
You could use a query that gets the two criteria from a form. In SQL view it would look like:

SELECT Field1, Field2, Field3
FROM TableName
WHERE
(Field1 = Forms!FormName.FirstTextbox AND Field2 = Forms!FormName.SecondTextbox)
OR
(Field2 = Forms!FormName.FirstTextbox AND Field1 = Forms!FormName.SecondTextbox)

Correct all the names and see if that works for you. Depending on the end goal, you could use that in any number of ways.
 

sparky23

New member
Local time
Today, 21:00
Joined
Feb 18, 2019
Messages
5
htt ps://ww w.access-programmers.co.uk/forums/attachment.php?attachmentid=73984&stc=1&d=1550591391

htt ps://ww w.access-programmers.co.uk/forums/attachment.php?attachmentid=73985&stc=1&d=1550591401

Hi,

thanks for fast respond.

I still can't attach pictures, it will be enabled after I make 10 posts.
Above are links where I added two spaces per link so the system can allow me post them.


I tried to write as little as possible to avoid long text and to bored someone.
I'll explain what I'm trying to make.
I need a data-base system that will help me to easily find a cable length between the racks and their patch panels.
So the program should contains different cable lengths between the points (one point is between two racks). This should be stored in some kind of variable, and then, depends of how high is patch panel positioned, to add on this variable two constant values for each side of the cable.
(Check the pictures, now I'm able to attach them).

#pbaldy has helped me to make a query that works partly for what I wanted at the first place.

I think it would be better if I run some VBA code that will search trough both columns where are stored (AA1 and AA2), and then
depend of results to dedicate value of the third column to one variable. (Every search should give only one unique record)

Then, VBA code should sum this variable with two constants and show me result in the form (in a text box for example).

I hope you guys have a clue what I'm trying to do.

Which approach would be best for me?

Thank you
 

Attachments

  • 2.png
    2.png
    15.8 KB · Views: 103
  • 3.png
    3.png
    41.5 KB · Views: 100

Users who are viewing this thread

Top Bottom