VBA Access Table Relationships

Hi,

I have an access database. I have two tables, please see below.

First table

name: tblTickers
fields
Ticker (text & primary key)
Name (text)
Sedol (text)

Open in new window


Second Table

name: tblTrade
ID (integer & primary key)
Ticker (text)
// some other fields

Open in new window


In this application a trade is entered into the table tblTrade. When this happens I would like a few things to happen.

1) If its a Ticker that doesn't already exist in tblTicker that it gets added and populates the other two fields, name & sedol.

2) If the ticker already exists in the tblTicker then nothing needs to happen.

3) If a ticker in the tblTrades is updated I would like the ticker in the tblTicker table to be updated too.

It looks like I should be using relationships between the two tables. However I do not know how to go about this, in particular on point 1) i.e. how would the name & sedol get updated?

I know I can achieve all of the above by using vba however it seems silly for me to have to write two update queries if there is already a mechanism in place.

Thanks for any help,
M
mcs26Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
I don't know what this database is tracking, but you logic (as far as database design is concerned) is not consistent with standard practices...
Also the brevity of your questions belies the actual scope of what needs to be done.

So, by what you posted, One Ticker can have many Trades
This is a standard one to many relationship:

<If its a Ticker that doesn't already exist in tblTicker that it gets added and populates the other two fields, name & sedol.>
This can be done, but you need to be good at VBA and form design, ...it may be simpler to just add the Ticker to the Ticker table first.

< If a ticker in the tblTrades is updated I would like the ticker in the tblTicker table to be updated too.>
The Ticker details may be updated, but the Ticket ID (the Primary key) will remain the same.
So any changes to the other fields in the Ticker table can be seen in a query joining the two tables.
 (in other words, only the Linking field (tickerID) will need to be duplicated in the tables.)

JeffCoachman


In a standard 1-to-many relationship, you would create a main form of the "Tickers" table, and a subform or Trades.
Then the very act of creating a Trade would automatically fill in the TickerID n the subform.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.