Enable/disable button based on lookup on another table

daninthemix

Registered User.
Local time
Today, 02:14
Joined
Nov 25, 2005
Messages
41
I have an 'associated' button on one form that jumps to another form and shows the associated record via the common field. However, that data may not necessarily be there - in other words, it'll be in the first form but the matching data may not be present in the other form, meaning it opens blank.

What's the best way to have Access lookup that data to see if it's there, and if it isn't to disable the button?
 
Maybe you could use a dlookup() here to see if anything is there before you actually open the form...
 
KenHigg said:
Maybe you could use a dlookup() here to see if anything is there before you actually open the form...

Thanks Ken. Can you help with the syntax? I've got

Code:
    Dim CarePackExists As Variant
    CarePackExists = DLookup("[Care Pack ID]", "Care Packs", "[Care Pack ID] = " _
    & Forms!Serials![Care Pack ID])
    cmdViewCarePack.Enabled = Not IsNull(CarePackExists)

Am I right in thinking this will pull the first value from FIELD Care Pack ID in table Care Packs where it matches the value in FORM serials, field Care Pack ID?
 

Users who are viewing this thread

Back
Top Bottom