Jump to content

Is there a Get (LastError )=401 for related record


This topic is 7430 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi,

In search mode, when no records are found, we can use the Get ( LastError )=401.

But within a relationship with the Go To Related Records script?

How can I know that no record is related ?

It's weird, because if the user clicks on a button with the Go To Related records script, and that no record is shown, then nothing happen.

Chris

Posted

One great advantage of relationships is that you can check BEFORE you use them. First, you need a field that you're sure has data in it in the related table; or at least would have data for that relationship, such as the right hand key of the relationship.

If [ not IsEmpty(relationship::field) ]

Go To Related Record ["relationship"]

Else

Do whatever if no match

End If

Posted

Thanks Fenton for your interesting idea. But in this case, I've forgotten to specify that it is a self joined relationship and a ">" type. The right hand key is thus always filled.

By the way, maybe I can explain why I use this scheme : I'm reluctant to use the perform find function, because I think relationships are faster. But it may be a false idea. What do you think ?

Posted

It doesn't make any difference. If there's none greater, the related field is empty, when you try to access it via the relationship. Try it. Yes, relationships are faster.

  • 5 weeks later...
Posted

Ah... I found something.

Just use the ErrorCode 101 ("record is missing").

set Error Capture (On)

Go to related record

if (Get(LastError)=101)

beep : "not found"

end if

Posted

No need to go to a related record when none exist. It's easier to do as Fenton wrote,

If [not IsEmpty(relationship::serial)]

Go to Related Record [show only related; relationship]

Else

Show Custom Dialog ["No related records exist."]

End If

If there are one or more related records, then relationship::serial (the right-hand key) will not be empty.

Posted

I use Count (relationship::keyfield ) > 0, but it has been suggested that this is slower.

Posted

Yes, if there are multiple related records, then Count would be slower. IsEmpty only checks the first related field and doesn't have to count anything, just return a boolean. I assume it would only need to test whether Left( field; 1 ) is empty. But I'm not sure if it does test the entire field. Either way, it would theoretically be faster.

This topic is 7430 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.