Using dlookup with an if statement in vba

marcusblackcat

New Member
Joined
Mar 11, 2015
Messages
18
H there. I've been a member for ages but am just getting to grips with access and have come across a little issue I need help with.

Im trying to write some code to only display certain fields if an entry selected from a different table has data in the corresponding second column.

i.e. I have a main table which has a field called "referred_from" and a secondary field called "further_info"

on on the main form, the "referred_from" field is always visible but the _"further_info" field is hidden.

the table (named tblreferrals) holds the "referred_from" and "further_info" but not all entries in this table have "further info" (i.e. We may have received a training referral from a small company without any specific departments (ab tyres for instance) or we may have received a referral from a large organisation with numerous departments - these would all have nitrites in the further info field.

so.. After rambling on.. I need a function which will basically display only the further info box if there is information win this on the tblreferrals.

im looking into using something wihich would basically say "if there is nothing in the further_info field then don't show the further info field on the form"

possibly "if (isnull(dlookup(further_info,tblreferrals,???) and I'm getting stuck and tearing out my hair!! Any chance of some help from a wizard!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Just to help you ask better questions, if you can give a visual, that helps explain what you're trying to accomplish... especially if you have difficulty explaining what you want in the first place.

If you want a quick answer, give a clear question. I have some links below that help assist you in writing clear questions, and for inserting some excel cells into this HTML code that we use on this website.

Please use these tools, and ask the question in a clear, visual way. Also, I've never heard of a "DLookup" function before. Make sure what you're asking exists, and what version of Excel you're using.
 
Last edited:
Upvote 0
Just to help you ask better questions, if you can give a visual, that helps explain what you're trying to accomplish... especially if you have difficulty explaining what you want in the first place.

If you want a quick answer, give a clear question. I have some links below that help assist you in writing clear questions, and for inserting some excel cells into this HTML code that we use on this website.

Please use these tools, and ask the question in a clear, visual way. Also, I've never heard of a "DLookup" function before. Make sure what you're asking exists, and what version of Excel you're using.

"dlookup" is an Access function not excel (hence the fact that it's in the Access folder!)

I have a drop down list in access which referes to another dropdown list in the same form
I would like to set it, using VBA, so that the second DDL only appears if there is something to select in there (i.e. if there are multiple options to select after your selection in the first ddl) - if the second list is blank, then I don;t want the further info box to appear as a selection

i.e. if (column1 in table1 is selected and column 2 in the same row of table 1 is empty, the ddl does not appear on the form otherwise it does)

Tried all sorts of things but can't get it working - have given up in the meantime!!
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,553
Members
449,038
Latest member
Guest1337

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