Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted (edited)

I'm not greatly experienced with FM, but I've done several databases. However, this is one of those cases that is probably easy buy has me running in circles.

I have three tables: Classes, Types, and Form. The Form is related to types by a type code and Types are related to Classes by a classcode, which is the first two characters of the type code. In a Form layout I have the type code, other information from the Type table, and the Class coming from the relationship Form>Types>Classes. All works well when I hand enter data.

However, I'm trying to implement a script to allow the user to enter a new type that will be added to the Type table and the Form table. All works well in creating the new records and the Form table showing the info from the Type table but after the record is created Form using a script, the class won't show on the Form layout. If, however, I go manually go into the field and erase one character and put it back in, it picks up the class.

Can anyone tell me what the problem is?

here is the script:

Set Field [ Globals::genTO; "" ]

Set Field [ Globals::genType; "" ]

Show Custom Dialog [ Title: "New General Item"; Message: "Type Order must be unique and in the form of nn-nn or nn-nn-nn. Type

must also be unique. Neither field can be empty."; Buttons: “OK”, “Cancel”; Input #1: Globals::genTO, "Type Order"; Input #2:

Globals::genType, "Type" ]

Go to Layout [ “GenTypes” (GenTypes) ]

New Record/Request

Set Field [ GenTypes::TypeOrder; Globals::genTO ]

Set Field [ GenTypes::Type; Globals::genType ]

Set Error Capture [ On ]

Commit Records/Requests

[ No dialog ]

If [ Get ( LastError ) ≠ 0 ]

Go to Record/Request/Page

[ First ]

Show Custom Dialog [ Title: "Error"; Message: "There was an error. Either the Type Order value or the Type value probably

already exists. Try again."; Buttons: “OK” ]

Delete Record/Request

[ No dialog ]

Go to Layout [ “FormData” (FormData) ]

Else

Set Error Capture [ Off ]

Sort Records [ Specified Sort Order: GenTypes::TypeOrder; ascending ]

[ Restore; No dialog ]

Go to Layout [ “FormData” (FormData) ]

New Record/Request

Set Field [ FormData::TypeOrder; Globals::genTO ]

Commit Records/Requests

[ Skip data entry validation; No dialog ]

Sort Records [ Specified Sort Order: FormData::TypeOrder; ascending ]

[ Restore; No dialog ]

Go to Field [ FormData::NumC ]

End If

Edited by Guest
Posted

I haven't fully followed your script but the behaviour you are describing would appear to indicate that the record in the class needs committing as I suspect that that is waht is happening when you go into the field and then come out of it again

HTH

Phil

Posted

That was my initial though as well, but I have tried various means of committing the record and nothing seems to work. As posted, the script has a commit record step for both the Types table and the FormData table. I've tried Going to the TypeOrder field, selecting it, etc. I've also tried created another new record and then deleting it but nothing has worked. I just noticed that if I run the script twice in a row, the first record shows the related value but the most recently created one doesn't.

this is driving me nut.

Posted

I finally got things working. I made a direct relationship between the FormData table and the Class table and that worked. I thought I had tried this before, but I probably didn't set it up right.

I thought I wouldn't have to do this as in another recent project I was suprised to learn that I could get data out of a table through a relationship with an intermediate table. That is what I tried here. It worked, except for the problem with getting the data to come up using the script. Anyway, on to new matters.

This topic is 6711 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.