My Assistant
![]() ![]() |
|
|
Aug 17 2006, 07:23 AM
Post
#1
|
|
|
UtterAccess Veteran Posts: 386 From: GA |
I have a form that has a button that is enabled if there are notes in a related table and disabled if there are no notes in the related table. I thought that using the dlokup function wwould be the quickest and easiest way to accomplish this. If there is a value returned from dlookup then enable the button otherwise disable it.
Now, on that line of code, I get an invalid use of null error. My code looks like this: CODE intOrgID = DLookup("OrgID", "OrgNote", "OrgID=" & intOrgID) If intOrgID < 0 Then Me.cmdViewNotes.Enabled = True Else Me.cmdViewNotes.Enabled = False End If Any assistance would be greatly appreciated. Thank you, Chester |
|
|
|
Aug 17 2006, 07:41 AM
Post
#2
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
Assuming you have a 'OrgID' control somewhere on your form, try:
Me.cmdViewNotes.Enabled = Nz(DLookup("OrgID", "OrgNote", "OrgID=" & Me.OrgID)) |
|
|
|
Aug 17 2006, 07:46 AM
Post
#3
|
|
|
UtterAccess Veteran Posts: 301 From: Florida |
The name of your field (intOrgID) is the same name as a field in the DLookup. That has to be wrong
|
|
|
|
Aug 17 2006, 08:10 AM
Post
#4
|
|
|
UtterAccess Veteran Posts: 386 From: GA |
Thanks niesz, if there is a related row in the notes table, the button is now enabled, however, if it is a new record and null, I now get the error "Syntax Error (missing operator) in query expression 'OrgID='. Any ideas on that one?
MiaAccess, I had been attempting to take the value of the field and assign it to the intOrgID variable and by placing the variable on the left and making it equal to the dlookup would normally work because the values on the right are read before the values on the left. Kind of like the code line: intCount = intCount + 1 That will read the intCount value on the right first, then add 1 to it and then assign it to the intcount variable on the left last. Thank you, Chester |
|
|
|
Aug 17 2006, 08:28 AM
Post
#5
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
If it is a new record, I guess we can assume that there is no corresponding Notes in the OrgNote table, so we need to set the button to disabled.
So try: If Nz(Me.OrgID) = "" Then Me.cmdViewNotes.Enabled = False Else Me.cmdViewNotes.Enabled = Nz(DLookup("OrgID", "OrgNote", "OrgID=" & Me.OrgID)) End If |
|
|
|
Aug 17 2006, 08:54 AM
Post
#6
|
|
|
UtterAccess Veteran Posts: 386 From: GA |
That did it. Thank you for the assistance! I am only asked to do an Access application about once a year and it is very hard to switch gears from using Access as a back end to an application to developing an entire application in Access.
Thank you, Chester |
|
|
|
Aug 17 2006, 08:57 AM
Post
#7
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
Glad you got it working.
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 21st May 2013 - 06:42 AM |