Error Message

Real Wally

Registered User.
Local time
Today, 11:32
Joined
Jan 28, 2003
Messages
107
Dear All,

Going through my records on a form using the forward button I get an error message when go to the new record.

The message indicates there's an operator missing in the expression: "PublicationID="


This expression is there to show or not show a label depending on a value and works fine otherwise.

After I get the error message I just click "end", the message disappears and I'm allowed to continue adding records.
Does anybody know what's wrong here?

The full piece of code for this label is:

If Nz(DCount("PublicationID", "tblPatent_DBs", "PublicationID=" & Me!PublicationID)) > 0 Then
Label85.Visible = False

Else
Label85.Visible = True

End If

Thanks for time,

Wally
 
Try...

Nz(DCount("[PublicationID]", "tblPatent_DBs", "[PublicationID]=" & [PublicationID]))
 
Is there any real point to using the Nz function there as if DCount can't find anything it returns 0 rather than Null.
 
Kevin, unfortunately your solution doesn't do the trick, I still get the same message.



Mile-O-Phile, unfortunately I'm in no position to give you any arguments for the choice made here as I am an absolute beginner with this stuff with only a minimal understanding of the code so far ( but I'm learning). I was offered this solution by someone else and it works fine except for the problem I've reported here. If you could offer an alternative (plus maybe an explanation) that'd be great though.

Cheers,

Walter
 
Personally, I prefer to put all field names within brackets althought there is no need (although there are exceptions to:

Try this, just in case:

If DCount("[PublicationID]", "tblPatent_DBs", "[PublicationID] = " & Nz(Me!PublicationID, 0)) > 0 Then


Otherwise, think about these questions?

PublicationID on your form...what sort of control is this?
What value does it have?
Is the ID numerical?
Is the form open?
Does PublicationID have a value at times when you need this code to run?
 
Last edited:
Thanks Mile-O-Phile,

The error message is gone and I'm able to go to a new record. Great!

Now, about your other questions:

>PublicationID on your form...what sort of control is this?
>What value does it have?
>Is the ID numerical?
>Is the form open?
>Does PublicationID have a value at times when you need this code to run?

-This field is there because I refer to it when opening further forms through buttons. It's an autonumber field and it doesn't contain a value when I open a new record. The code runs on opening the form so when I add a new record from an open form it doesn't find a number in that field? Is that what caused the problem you think?



Walt
 
Yep, going to a new record and trying to calculate on it when it doesn't actually exist yet was the problem as the record isn't actually created until information is put into the record.

That's why I thought it would be best to Nz around the control rather than the full expression.
 

Users who are viewing this thread

Back
Top Bottom