How to make a blank field move to the next field?...

radar2000

Board Regular
Joined
Apr 15, 2002
Messages
85
Hi everyone.

Does any know how to instruct Access to move to the next available field when it encounters a blank field? For example:

If you have 3 address fields

Address1
Address2
City

If Address 2 contains blank data, I would like Access to do the following:

Address1
City

I don't want Access to do this:

Address1
<Blank>
City

Any suggestions would be appreciated.

Thank you.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi, in what context do you want to do this? On a form or a report?
Andrew
 
Upvote 0
Assuming these control and field names:

txtAdd1 = [address1]
txtAdd2 = [address2]
txtCity = [city]

Try using formulas instead of the field name like:
txtAdd1 = Iif(isnull([address1]), [address2], [address1])
txtAdd2 = Iif(isnull([address2]), [city], [address2])
txtCity = Iif(isnull([address2]),null,[city])

This assumes at least one address. If there is sometimes no addresses at all, you'll have to nest another If statement.

An alternative would be to pull these pieces of data as records in a single field in a query and then sort the query.

Hope this helps,
 
Upvote 0
Corticus said:
Assuming these control and field names:

txtAdd1 = [address1]
txtAdd2 = [address2]
txtCity = [city]

Try using formulas instead of the field name like:
txtAdd1 = Iif(isnull([address1]), [address2], [address1])
txtAdd2 = Iif(isnull([address2]), [city], [address2])
txtCity = Iif(isnull([address2]),null,[city])

This assumes at least one address. If there is sometimes no addresses at all, you'll have to nest another If statement.

An alternative would be to pull these pieces of data as records in a single field in a query and then sort the query.

Hope this helps,

Hi Corticus.

That did the trick! :pray:

Thank you everyone for all your help.
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,242
Members
451,756
Latest member
tommyw

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