Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If a record exists, then disable this command button

Status
Not open for further replies.

cruz610

Programmer
Jun 18, 2004
18
US
Can someone help me out with coding this form OnLoad event? I want to see if a certain record exists in the database and if it does disable a button that runs a query. If it does not exist then enable it. I also need this code for after the button is run. It will see if records exist if they do then its disabled. Thanks for the help!
 
Take a look at the DLookUp function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yes, I have been playing around with DLookup, but with no success. Here is the code I have been using that does not work:
Code:
IIf(IsNull(DLookup("numFTEID", "tblTransFTE", "[tblTransFTE].[numTransactionID]=[numTransactionID]")), Forms!frmClients.cmdAddAssumptions.Enabled = True, Forms!frmClients.cmdAddAssumptions.Enabled = False)
Basically it is checking to see if numFTEID is null where the numTransactionID is the current loaded record. However, there are 77 FTEIDs per transaction so I dunno if that will effect the way it works.
 
Something like this in the Current event procedure of you form:
Forms!frmClients!cmdAddAssumptions.Enabled = IsNull(DLookup("numFTEID", "tblTransFTE", "numTransactionID=" & Me!numTransactionID))
BTW, the frmClients form must be open.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV's is far better, and you seem to be a bit confused on the syntax of the IIF function. Given your example above, the proper syntax would be as follows:
Code:
[Forms]![frmClients]![cmdAddAssumptions].Enabled = IIf(IsNull(DLookup("numFTEID", "tblTransFTE", "[tblTransFTE].[numTransactionID]=[numTransactionID]")), True, False)
Again, I show this only to illustrate the proper use of the IIf function in an assignment statement.



Good Luck
--------------
To get the most from your Tek-Tips experience, please read FAQ181-2886
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top