Lookup entered value's mate in another table,insert mate in next f

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there

This should be a fairly straightforward question for you.
Problem:
One company comprises of many subsidiary companies.
Solution required:
When I enter a sub co in field A, I would like the holding co name to be
returned in adjacent field B (same record/row).
Question:
What is the most effective way to achieve this?

Any help would be greatly appreciated (please just bear in mind I'm still at
beginner level).

Many thanks
Will
 
Hi Will

There is more then one way of skinning the bear, here is my suggestion:

tblCompanies (that the parent Company)
Company_ID key
CompanyName (text)
etc.

tblSubsiaries
Subsid_ID (key)
Company_ID (long - foreign Key)
SubdisName (txt)
etc

Create relation One-To-Many on Company_ID
(Be sure not use the words "Sub" , "Parent" or "Name" as field name as
those are reserved words)

Create a query based on both tables (linked on Company ID) where the first
filed is the subsidiary name and the second field is the (parent) Company
Name

Regards/JK
 
Thanks JK.

Unfortunately you really have a really big bear / beginnner on your hands
here.

I have created the tables as recommended below. One prob though: my
inherited subsidiaries property database is 9000 records long, with
tblCompanies having blank records under the Company_ID. So I can't set up a
primary key on that field, and I don't get a one to many relationship
(instead it reads indeterminate). Nevertheless.

I have tried without success to create an update query that will look in the
tblSubsidiaries and return the Company_ID alongside the SubsidName (entered
in tblCompanies).

Just to clarify, my objective is to do the following:
1. Enter SubsidName in tblCompanies in a form
2. Hit query button / run query
3. Access to return the Company_ID corresponding to that SubsidName entered
(from tblSubsidiaries)

Appreciate your help
Will
 
Hi Will,

No worries mate, we can skin a big bear but we need get it first :)

I'm not too clear on what you have.

Firstly, are we talking about Property Management DB, Real Estate DB? or
similar, if so, my approach is not quite appropriate. I understood it to be
a situation of a corporate with subsidiary companies/branches.

It is most important that you mention the type of business because there
sure to be some people here who have written program for your type of
business, let alone talk to you the "lingo"

What is the type of business we are talking about?

Secondly,Your "inherited subsidiaries property database" (with 9000
records), is that in an Access database?
If so can you please give me the structure of the table where those 9000
records reside, this will enable me to be more specific.

If it is not Access DB, can you generate an export file from your db (Excel,
comma delaminated )?

Await your reply before we start skinning

Regards
Jacob
 
Hi Jacob

Appreciate this! Hope you had a good weekend.

Some background is definitely appropriate here.
We are investment property brokers.
Our objective is to create and maintain a database of investment properties
and their owners.

The database is being created from scratch – ie no reliance on Property
Management or Real Estate DB. What are your thoughts on this?

A lot of owners buy properties using different companies. For example,
holding company Apple will buy properties using legal entities Silver, Nickel
and Iron.
I wish to automatically link the effective subsidiaries to the holding
company.
So when a user types in the subsidiary (Silver, Nickel or Iron) Access
returns either:
1) message saying: "Subsidiary is not in companies' database, please
update", or
2) in adjacent field, the relevant holding company name is automatically
entered.

The “inherited subsidiaries property database†with 9000 records is an
Access database.

Currently the huge majority of subsidiary and owner fields are vacant and
being completed as information is updated.
The table is comprised mostly of property-specific fields.
The holding / main company field is a drop down combo box, with values
derived from the owners (mainly legal entities) table.
(One of the objectives here is to identify players we don’t currently have
dealings with, and to ensure we track our communications, or lack thereof,
with the chaps.)

Hope this helps you. Please let me know if you require any further info.

Best wishes
Will
 
Ok Will, I think that I got the picture

Let's start from scratch

tblOwners (The Holding Companies e.g Apple)
-----------
Owner_ID AutoNumber, Key
OwnerName (Txt) e.g Apple
OwnerAddress (Memo or 2-3 Address Lines: OwnerAddress1, OwnerAddress2,
(OwnerAddress3)
OwnerCity/Town/Suburb Txt
OwnerState Txt (if applicable)
OwnerCountry (Text If Applicable)
OwnerPostCode/Zip (Text
OwnerPhone (txt)
......
etc, contact names, reg no etc.
.......
LastActivityDate (date/time)
or
IsActive (Yes/No)

(the slash / is only an altenative do not use slash in a field name)

Comment : Towns, States and Country can be created in 3 separate tables (but
this will entail a lot of additional initial work and maintenance, unless
you can get hold of such tables). Advantage: eliminate spelling differences,
misspelling and enure accurate search results, if required. You would
probably need similar fields in the Subsidiaries and presumably in the
Properties table. If you go this way than Town_ID, State_ID, Country_ID (all
Long Integers, instead of text)


TblOwnersCompanies (This is your Iron, Silver,Nickel Table)
----------------------
OwnerCo_ID Autonumber (Key)
Owner_ID (long-foreign key, linking the subsidiaries to their
respective Owners
OwnerCoName (txt) e.g Silver
.......
Other fields as required
........

Create a one-to many relation on Owner_ID between the two tables

To Locate an Owner By subsidiary:

Create a query using the two tables, linked on Owner_ID,
First Column: OwnerCoName (sorted)
Second Column: OwnerName (From tblOwners)
Third Column: Owner_ID from *tblOwnersCompanies* (a must)
Fourth Column: OwnerCo_ID

Later on a Form you will be able to create a combo box (drop down List)
which will show both the subsidiary company name and the "real" Owner name.
This will eliminate spelling error when you search by just typing in names

If a subsidiary can have more then one property, probably unlikely but
possible, you will also need a Properties table which hold information about
the *property* incl its legal owners (using OwnerCo_ID) and linked
one-to-many to tblOwnersCompanies on OwnerCo_ID

This will enable yo to find the "real" owner from the property or group all
the properties for one Owner etc

Naturally you will use your own naming convention. As I mentioned before, be
sure not to use reserved words as table or field names e.g: "Name", "Sub",
"Date", "Time" being the most common traps .

I suggest that at this stage we'll forget about the 9000 table until you
have a structure in your new DB. We'll find a way to import data, if need
be, at a later stage


Hopefully that is enough to get you started.

Regards
Jacob
 
Hi Jacob

I'm going to apologise in advance in case I am misunderstanding you. Also
for my arbitrary use of Capitals, but they might make things clearer.

A.1

Thank you. I have the 9000 records imported from Excel into my Access
Database, with relevant fields and tables, combo boxes etc set up.

A.2

Thank you for the query info. I just don't know how to integrate this to
achieve what I need (please refer below, esp how Excel would achieve this,
thank you)

My problem is this, and I might be missing your point here. And for that I
apologise in advance...

what I am trying to do is enter:
"OwnerCoName" (Sub Co, eg Zinc) in a form in the massive 9000 record
database, and have it AUTOMATICALLY return, after pressing a command button,
either:
1) a value in adjacent field: "OwnerName" (or Holding Company, eg Apple), or
2) message saying: "Subsidiary is not in companies' database, please update"

Saying it another way:
enter:
Sub Co, eg Silver, in a form in the massive 9000 record database, and have
it AUTOMATICALLY return, after pressing a command button, either:
1) a value in adjacent field: Holding Company, eg Apple, or
2) message saying: "Subsidiary is not in companies' database, please update"

Maybe I need to change my thinking, but: Best case scenario is I don't press
a command button, BUT, LIKE EXCEL'S VLOOKUP FUNCTION, THE OWNER NAME IS
AUTOMATICALLY RETURNED. Is a similar operation possible in Access?

I am fully prepared to set up a table linking the many many Sub Co's (Eg
Silver, Nickel, Iron and Red, Green, Yellow, Blue and Oak, Maple) to many
Holding Companies (Eg Apple and Properties Fifteen and Jaguar)

I have used masks too so Owner_ID's are reflective of the Holding Co name,
and utterly unique.

Subsidiaries do generally have more than one property in them. So it isn't a
train smash if in my main 9000 records data base these sub's, and their
holding companies, reoccur.

A.3

Unfortunately I can't link 9000 record database with Sub Names (being
entered as deed searches are performed) to your TblOwnersCompanies field.
(Fyi my TblOwnersCompanies field uses my tblOwners for its OwnerName drop
down combo box)

This might be because, at this stage, their is no primary key set up. My
primary key is to be the Title Deed info for each property, again set up as a
mask, and unique. However at this stage the Title Deed info needs to be
captured onto the database, so many records for this field are blank.

Many thanks
Will
 
Hi Will

Please read below

Will_Harris_ZA said:
Hi Jacob

I'm going to apologise in advance in case I am misunderstanding you. Also
for my arbitrary use of Capitals, but they might make things clearer.

A.1

Thank you. I have the 9000 records imported from Excel into my Access
Database, with relevant fields and tables, combo boxes etc set up.

A.2

Thank you for the query info. I just don't know how to integrate this to
achieve what I need (please refer below, esp how Excel would achieve this,
thank you)

My problem is this, and I might be missing your point here. And for that I
apologise in advance...

what I am trying to do is enter:
"OwnerCoName" (Sub Co, eg Zinc) in a form in the massive 9000 record
database, and have it AUTOMATICALLY return, after pressing a command
button,
either:
1) a value in adjacent field: "OwnerName" (or Holding Company, eg Apple),
or
2) message saying: "Subsidiary is not in companies' database, please
update"

Saying it another way:
enter:
Sub Co, eg Silver, in a form in the massive 9000 record database, and have
it AUTOMATICALLY return, after pressing a command button, either:
1) a value in adjacent field: Holding Company, eg Apple, or
2) message saying: "Subsidiary is not in companies' database, please
update"

Maybe I need to change my thinking, but: Best case scenario is I don't
press


You certainly need to change your thinking, many newcomers to Access from
Excel look at Access as a "better" Excel - this is not the case! Access is
Database application which hanles data in a diffrent way, dont get mislead
just because you can disply data in Access in a table resembling the "look"
of Excel.

a command button, BUT, LIKE EXCEL'S VLOOKUP FUNCTION, THE OWNER NAME IS
AUTOMATICALLY RETURNED. Is a similar operation possible in Access?


The equevalent to VLOOKUP() , but more powerfull in Access is the DLookup()
function.
If I understood you correctly, here is how use DLookup():

Suppose You have a text box "txtSearchCompany" and a command button next to
it "btnSearchCompany". You create On Click event procedure for the button

(untested)
+++++++
Private Sub btnSearchCompany_Click()
Dim TmpCompany as Variant

' Check That there is a value in txtSearchCompany, Exit if none
If Len(Me.txtSearchCompany)=0 then
MsgBox "No Value to search For!", vbExclamation,"Cannot Search For
Blank"
Exit Sub
End If

'Look For Holding Company By it's subsidiary
tmpCompany=Dlookup("[OwnerName]","tblSubsidiaries","[SubCompany]=' " _
& txtSearchCompany & " ' ")

'Remove spaces from ' " and " ' " (I placed them for clarity only)
'Change the names as per the table (9000) and its fields

'Display Results
If IsNull(tmpCompany) Then
MsgBox "Subsidary Does Not Exists or have no Holding Company"
Else
MsgBox "Holding Company Of: " & Me.txtSearchCompany & " Is " &
tmpCompany
End If

End Sub
++++++++++++++

However, you can still create a combo Box to do the same more efficiently
(see futher down here)
I am fully prepared to set up a table linking the many many Sub Co's (Eg
Silver, Nickel, Iron and Red, Green, Yellow, Blue and Oak, Maple) to many
Holding Companies (Eg Apple and Properties Fifteen and Jaguar)

You seem to misundstand the concept of liking. One-to-Many mean One
Holding Company can have many Subsidiaries, You can have as many Parent
Companies as you wish, *each* Parent can have none, one or more
subsidiaries - *but *a subsidairy cannot have more than one parent Company.
I have used masks too so Owner_ID's are reflective of the Holding Co name,
and utterly unique.

masks control how date is entered, not how its stored, although it can do
that too
Subsidiaries do generally have more than one property in them. So it isn't
a
train smash if in my main 9000 records data base these sub's, and their
holding companies, reoccur.

Create a Prperty Table And Link it one-ToMany (the prperty is the many side)
A.3

Unfortunately I can't link 9000 record database with Sub Names (being
entered as deed searches are performed) to your TblOwnersCompanies field.
(Fyi my TblOwnersCompanies field uses my tblOwners for its OwnerName drop
down combo box)


You can use tblOwnersCompanies as basis for for you combo, your combo can be
based on the same table or query as the form, no restriction there

if you do that you can search the 9000 for holding comapnies more
efficiently - this is what I meant here above
This might be because, at this stage, their is no primary key set up. My
primary key is to be the Title Deed info for each property, again set up
as a
mask, and unique. However at this stage the Title Deed info needs to be
captured onto the database, so many records for this field are blank.

You can use the Title Deed as primary key *provided that* you *always have*
a Title Deed, although I will recomand using AutoNumber. In any event you
will need a primary key for the other tables
Many thanks
Will

To add a Primary key to your exiting subsidiary company:
Rename the Old Table (say, Add "OLD" to its name (no quatation marks)
Create a new table with the original name and with exactly the same fileds
as you existing table. Insrerst a primary Key as the first filed make it
AutoNumber, increament

Craete an *Append Query* and import all 9000 records from the old table to
the new one - Access will allocate the primary key to all the recordes in
the new table (keep the old table for refference and backup)

Will, if you wish me to have a look at your DB, your are welcome to Zip it
and send it to me:
(sarichart at ozzienet dot net). if you do so please put in subject Line
"Will's DB" or somthing that will distinguish you e-mail form a spam

Regards
Jacob

 
Hi users

The answer to my question can be found in the following question:

DLookup enquiry - automated data entry in forms

Best wishes

Hi Jacob

My deepest gratitude for your detailed reply. For some reason I hadn't
picked up your response, and I thought this trail had died.

I found an answer to what I needed using combo boxes, and some very basic
coding. I am very busy at the moment. When I get some time I will attend to
your mail in detail.

Thank you for the investment in time, and your kind offer to email the db
through. I'm off for 4 weeks in Africa, but when I get back will get back
into Access in serious fashion.

Have a happy and safe festive season

Will

JK said:
Hi Will

Please read below

Will_Harris_ZA said:
Hi Jacob

I'm going to apologise in advance in case I am misunderstanding you. Also
for my arbitrary use of Capitals, but they might make things clearer.

A.1

Thank you. I have the 9000 records imported from Excel into my Access
Database, with relevant fields and tables, combo boxes etc set up.

A.2

Thank you for the query info. I just don't know how to integrate this to
achieve what I need (please refer below, esp how Excel would achieve this,
thank you)

My problem is this, and I might be missing your point here. And for that I
apologise in advance...

what I am trying to do is enter:
"OwnerCoName" (Sub Co, eg Zinc) in a form in the massive 9000 record
database, and have it AUTOMATICALLY return, after pressing a command
button,
either:
1) a value in adjacent field: "OwnerName" (or Holding Company, eg Apple),
or
2) message saying: "Subsidiary is not in companies' database, please
update"

Saying it another way:
enter:
Sub Co, eg Silver, in a form in the massive 9000 record database, and have
it AUTOMATICALLY return, after pressing a command button, either:
1) a value in adjacent field: Holding Company, eg Apple, or
2) message saying: "Subsidiary is not in companies' database, please
update"

Maybe I need to change my thinking, but: Best case scenario is I don't
press


You certainly need to change your thinking, many newcomers to Access from
Excel look at Access as a "better" Excel - this is not the case! Access is
Database application which hanles data in a diffrent way, dont get mislead
just because you can disply data in Access in a table resembling the "look"
of Excel.

a command button, BUT, LIKE EXCEL'S VLOOKUP FUNCTION, THE OWNER NAME IS
AUTOMATICALLY RETURNED. Is a similar operation possible in Access?


The equevalent to VLOOKUP() , but more powerfull in Access is the DLookup()
function.
If I understood you correctly, here is how use DLookup():

Suppose You have a text box "txtSearchCompany" and a command button next to
it "btnSearchCompany". You create On Click event procedure for the button

(untested)
+++++++
Private Sub btnSearchCompany_Click()
Dim TmpCompany as Variant

' Check That there is a value in txtSearchCompany, Exit if none
If Len(Me.txtSearchCompany)=0 then
MsgBox "No Value to search For!", vbExclamation,"Cannot Search For
Blank"
Exit Sub
End If

'Look For Holding Company By it's subsidiary
tmpCompany=Dlookup("[OwnerName]","tblSubsidiaries","[SubCompany]=' " _
& txtSearchCompany & " ' ")

'Remove spaces from ' " and " ' " (I placed them for clarity only)
'Change the names as per the table (9000) and its fields

'Display Results
If IsNull(tmpCompany) Then
MsgBox "Subsidary Does Not Exists or have no Holding Company"
Else
MsgBox "Holding Company Of: " & Me.txtSearchCompany & " Is " &
tmpCompany
End If

End Sub
++++++++++++++

However, you can still create a combo Box to do the same more efficiently
(see futher down here)
I am fully prepared to set up a table linking the many many Sub Co's (Eg
Silver, Nickel, Iron and Red, Green, Yellow, Blue and Oak, Maple) to many
Holding Companies (Eg Apple and Properties Fifteen and Jaguar)

You seem to misundstand the concept of liking. One-to-Many mean One
Holding Company can have many Subsidiaries, You can have as many Parent
Companies as you wish, *each* Parent can have none, one or more
subsidiaries - *but *a subsidairy cannot have more than one parent Company.
I have used masks too so Owner_ID's are reflective of the Holding Co name,
and utterly unique.

masks control how date is entered, not how its stored, although it can do
that too
Subsidiaries do generally have more than one property in them. So it isn't
a
train smash if in my main 9000 records data base these sub's, and their
holding companies, reoccur.

Create a Prperty Table And Link it one-ToMany (the prperty is the many side)
A.3

Unfortunately I can't link 9000 record database with Sub Names (being
entered as deed searches are performed) to your TblOwnersCompanies field.
(Fyi my TblOwnersCompanies field uses my tblOwners for its OwnerName drop
down combo box)


You can use tblOwnersCompanies as basis for for you combo, your combo can be
based on the same table or query as the form, no restriction there

if you do that you can search the 9000 for holding comapnies more
efficiently - this is what I meant here above
This might be because, at this stage, their is no primary key set up. My
primary key is to be the Title Deed info for each property, again set up
as a
mask, and unique. However at this stage the Title Deed info needs to be
captured onto the database, so many records for this field are blank.

You can use the Title Deed as primary key *provided that* you *always have*
a Title Deed, although I will recomand using AutoNumber. In any event you
will need a primary key for the other tables
Many thanks
Will

To add a Primary key to your exiting subsidiary company:
Rename the Old Table (say, Add "OLD" to its name (no quatation marks)
Create a new table with the original name and with exactly the same fileds
as you existing table. Insrerst a primary Key as the first filed make it
AutoNumber, increament

Craete an *Append Query* and import all 9000 records from the old table to
the new one - Access will allocate the primary key to all the recordes in
the new table (keep the old table for refference and backup)

Will, if you wish me to have a look at your DB, your are welcome to Zip it
and send it to me:
(sarichart at ozzienet dot net). if you do so please put in subject Line
"Will's DB" or somthing that will distinguish you e-mail form a spam

Regards
Jacob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top