Premium Only Content
Conditional Display of Company or Person Name in Microsoft Access
Today's TechHelp tutorial from Access Learning Zone covers how to display either a person's name, a company name, or both conditionally in your Microsoft Access database.
Marcellino from Hefsabud, Georgia, one of our silver members, has asked a great question. In his table, he stores fields for company name, first name, and last name. Sometimes, he has all three, but other times he only has a company name or a person's name. He wants to ensure that when printing statements, the company name shows up if it's available, and if not, the person's name is printed instead.
There are a couple of ways to achieve this. First, I'll show you a basic method that involves adjusting some property settings on your reports. Then, I'll share a more advanced solution that doesn't require programming but will involve a few functions. The advanced method yields better results, but the beginner method is sufficient if you're looking for something quick and simple.
Before we dive in, make sure you've completed my Access Beginner Level One course. It's free and available on my website and YouTube channel. Also, familiarize yourself with the Can Grow and Shrink functionality, which allows fields without data to disappear on your reports.
Let's start with the beginner method. I'll use my TechHelp free template, which you can download from my website. This template includes a customer form with personal information, such as first name, last name, and address. I'll add a company name field to the customer table.
First, open the table in design view and add the company name field below the first and last name fields. Switch to datasheet view and enter some sample data. You should have a mix of records: some with both company and personal names, some with only company names, and some with only personal names.
Next, open a blank report template where I've set up basic settings like margins. Duplicate this template and name it something intuitive like "Customer Report." In the design view of this report, set the record source to the customer table. This ensures the report pulls data from the correct table.
Add the necessary fields from the customer table to the report: first name, last name, company name, and address. For aesthetic purposes, remove the default labels, arrange the fields in an address block format, and resize them as needed.
Save the report and preview it. Initially, you'll notice that some records will display blank fields, depending on the data. To make these fields disappear when they are empty, enable the Can Shrink property for the text boxes and the detail section of the report. This makes sure that if there's no data in a field, it won't display extraneous blank space.
After adjusting the properties, save and preview the report again. Empty fields should now be hidden, making the report look cleaner.
While this method is straightforward, you might be looking to add more professional touches, such as a conditional statement like "Statement prepared for" followed by either the company name or the person's name. For that, we can use a query and some functions, which I'll cover in a future video.
This concludes today's tutorial. If you want step-by-step instructions and a complete walkthrough, visit my website for a full video tutorial.
Live long and prosper, my friends.
For a complete video tutorial on this topic, please visit https://599cd.com/CompanyorPerson?key=Rumble
-
LIVE
The HotSeat With Todd Spears
1 hour agoEP 203: The Military "Whistleblower"
800 watching -
LIVE
The Nunn Report - w/ Dan Nunn
1 hour ago[Ep 784] Election 2025: NYC is Screwed | Tatum Calls Out Kirk Conspiracists | Guest: Sam Anthony
172 watching -
1:22:54
DeVory Darkins
4 hours agoTrump makes shocking announcement as Major ELECTION UPDATE drops after bomb threat
91.8K56 -
10:11
Dr. Nick Zyrowski
8 days agoDoes Creatine CAUSE Hair Loss? (We All Got This Wrong)
13.9K2 -
1:09:24
Timcast
5 hours agoZohran Mamdani BLAMES Trump Over Bomb Threats At Polling Locations
169K108 -
3:09:52
Right Side Broadcasting Network
6 hours agoLIVE REPLAY: White House Press Secretary Karoline Leavitt Holds a Press Briefing - 11/4/25
80K18 -
1:58:04
The Charlie Kirk Show
4 hours agoGo Vote! + Healthcare and the Shutdown | Dr. Oz, Baris | 11.4.2025
89K18 -
58:49
The White House
5 hours agoPress Secretary Karoline Leavitt Briefs Members of the Media, Nov. 4, 2025
38.1K17 -
1:00:22
Sean Unpaved
4 hours agoCarousel Chaos: CFB Week 10 Shocks & Drops, Cardinals Stun MNF, & CBB's Opening Tip-Off Frenzy
33K1 -
1:57:43
Steven Crowder
7 hours agoFailed Hit Job: Another Trump Media Hoax Exposed
416K383