Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I use 2 Fields but make one the "master" field

Status
Not open for further replies.

bkirkpatrick

Programmer
Dec 8, 2003
29
US
I am creating a Donations db and have a table and in this table, donators can be either a person or a business. Fields: LastName and FirstName make the “person” (via an expression) and the “business” is derived from field: BusinessName. a donator can only be one or the other. My dilemma is that I want to be able to down the road manipulate the data (ie alphabetical by LastName and BusinessName, and for sending mass thank you letters).

The only way I can think of doing this is creating a Field in this table called something like PrimaryName and then via VB code in the form (on some event or button I insert) force the PrimaryName field to be either the combination of the FirstName and LastName or just the BusinessName. This could be done by a trigger from a combo box on the form (cboDonatorType) which the user would select indicating whether it was a (1) Person or a (2) Business that made the donation.

Code:
If me.cboDonatorType = 1 then me.PrimaryName = Me.FirstName&” “&Me.LastName
Else
Me.PrimaryName = BusinessName

The code is easy but am I making this too difficult?
 
Hi.

It seems simpler to me.

If there is anything in Business name, then business name, else First and last name.

Danger is what if a user enters in both, so you could disable the appropriate form objects as necessery, using the after update events, and the on current events.

ChaZ

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
That was the first way I was going to do it but I know that some of the users would do both.

That is why I was going to create a combox box or checkbox to indicate if it was a business or not. That would trap the appropriate resopnse.
 
How are ya bkirkpatrick . . .

Let a query do the work with a [blue]Custom Field[/blue]:
Code:
[blue]PriName: IIf(IsNull([BusinessName]),[LastName] & " " & [FirstName],[BusinessName])[/blue]

Calvin.gif
See Ya! . . . . . .
 
Hi. I was thinking that if after a user pokes anything into say company name, the after update event says something like

me.Firstname.enabled = false
me.Lastname.enabled = false

And same with the names, so the users can't poke into both spots.

Either this, or the combo would work I suppose.

ChaZ

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
TheAceMan1 nailed it. Just shoved the code into my query and it works perfectly.

Blorf: I am going to is the visible mode and just togle them on and off.

Thanks,

Perfect end to a good day!

Brendan
 
In the query there is no need to create an extra column:
SELECT * FROM yourTable
ORDER BY Nz(BusinessName,LastName & ' ' & FirstName)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top