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
GritsGG
5 hours agoWorld Record Win Streak Attempt! #1 Most Wins 3880+!
43 watching -
LIVE
The Rabble Wrangler
15 hours agoBattlefield with The Best in the West
63 watching -
13:56
Cash Jordan
2 hours ago"OPEN BORDERS" Mob BATTERS Portland Jail… 'COMBAT' Marines DEFY Judge, BREAK BONES
4.92K7 -
16:44
Russell Brand
3 hours agoAmerica’s Hidden Royalty
29.4K26 -
LIVE
LumpyPotatoX2
3 hours agoLightyear Frontier: Gameplay Showcase - Sponsored Stream
39 watching -
LIVE
ReAnimateHer
8 hours ago $0.13 earnedSurviving the Undead in Cold War Zombies
24 watching -
1:44:25
Redacted News
2 hours agoElection Day Disaster for Trump? Europe preps for WAR against Russia, Israel's PR failure | Redacted
71.5K84 -
LIVE
Wayne Allyn Root | WAR Zone
8 hours agoWatch LIVE: The War Zone Podcast with Wayne Allyn Root
58 watching -
33:39
LibertyRoundTable
4 hours agoWarhawk Down: Dick Cheney’s Legacy & the Rise of Citizen Journalism | LRT Radio 11/4/25”
2.91K1 -
2:05:29
The Quartering
5 hours agoEscape From New York, Harvard Bombers Caught, Trump DEFIES Court On SNAP, Bomb Threat On Plane!
153K88