Need to create new column in access table that looks at two other columns (If, then, else)

Maggie Barr

Board Regular
Joined
Jan 28, 2014
Messages
188
Hello, and thank you in advance if you can help,
I think what I am trying to do should be pretty easy, and I have tried several things, but I keep getting syntax errors. I want to create a column for NEW_EVENT_ID that is If Group_ID is blank then Sampling_EVENT_ID else Group_ID. I have tried so many times, and searched on line, but I can't make it happen. I am trying to do this in a table created from a query, but I could do it in the query if it would work better. I could do this in Power Query, which is where I am headed with the data, but it was running so slow in the past that I am trying to do as much data manipulation in another format.
Any advice would be greatly appreciated,
Maggie Barr
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
It is always recommended to do Calculated Fields in a Query rather than a Table.
Recent versions of Access allow you to do limited calculations at the table level, but it really isn't advised. It is better to do them at the Query level.
 
Upvote 0
Joe4,
Thank you for that, and I had tried some, but whatever I was doing was not working. Could you please let me know how to get started on the right path to performing this. I am very new to Access, and the language/syntax is not like excel or Power Query.
Thank you,
Maggie
 
Upvote 0
Here is one way, using the Nz function (which tells it what to return instead of a field if that field is null/empty):
Code:
NEW_EVENT_ID: Nz([Group_ID],[Sampling_EVENT_ID])
 
Upvote 0
Joe4,
THANK YOU SO MUCH! Yes, that worked great, I really appreciate your help.
If you have any advice on the best books to learn Access & syntax, please let me know. I am trying to learn to fish good enough to feed myself...
Best Wishes,
Maggie
 
Upvote 0
If you just want to learn how to use Access, I used the Microsoft Step-by-Step series as a good introduction (though that was many years ago, and there are many other good books and tutorials).
If you are going to be creating database applications with Access, it is important to have a good understanding of Relational Database Theory and Design, especially the Rules of Normalization.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,492
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top