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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fieldValue and currRecord

Status
Not open for further replies.

PALman

Technical User
May 15, 2002
160
GB
I have four tables with a common key field named SerialNo.
This is the first field in three of the tables and is the second field in one and in this one I have created a secondary index on this field.
If I open the form for table #1 and move to a particular record, I want to read the actual current value of the SerialNo field, store it as a variable and carry it over to open a form of say table #2, search for that value and display that form with all the fields for that particular SerialNo.
The end result would be to switch, at the press of buttons on the forms, between each of the four tables and display the same Serial No and all the its data each time.
I have linked the tables together in the Data Model and have tried using fieldValue and currRecord but they seem only to return True and False.
I have been able to switch between the table forms easily and have managed to store a variable using…
tc Tcursor
fldVAL AnyType
However when opening a Tcursor this always returns the value of the FIRST record SerialNo field.
Can anyone help please?
 
You don't say, but I presume SerialNo only contains unique values.
Many ways to accomplish what you want. If you are using V8 or above, it may be simplier to use tabbed pages instead of separate forms, and that would make a solution easier (just a suggestion).
Here is the bones of a pushbutton code (on Form1) to go from Form1 to Form2, assuming you have already moved to the record you want in Form1:

method pushButton(var eventInfo Event)
var
someFrm Form
endvar

;first try to attach to Form2 because it may already be open
;instead of <form title> insert the correct title for Form2 as it appears in the title bar
if not someFrm.attach(&quot;<form title>&quot;) then
if not someFrm.open(&quot;:WORK:FORM2.FSL&quot;) then
;use your own filename for Form2
errorShow()
return
endif
endif
;Form2 is open and someFrm is attached to it
;locate the required serialNo
;assumes SerialNo is on both Form1 and Form2
if not someFrm.SerialNo.locate(SerialNo.value) then
msgStop(&quot;Cant find Serial Number&quot;)
return
endif
someFrm.bringToTop()

endMethod
 
Sorry - it should be:

if not someFrm.SerialNo.locate(&quot;SerialNo&quot;, SerialNo.value) then
 
Thanks OGriofa,
I am using Paradox 7. Tabbed pages not really what I am looking for.
The code you gave, looks like just what I need.
However I get an &quot;Unknown Identifier&quot; error in the line you corrected. I have tried both lines and get the same error.
i.e....
if not someFrm.SerialNo.locate(SerialNo.value) then
if not someFrm.SerialNo.locate(&quot;SerialNo&quot;, SerialNo.value) then
Thanks for any further help!
 
mmm... As I said, I assumed that you had the SerialNo as a field on each form. What I didn't say was that I was also assuming that this field could be accessed by simply describing it by &quot;SerialNo&quot;. If you have this field in a container (a box, a MRO, even a page) which is named - i.e. the name of the container(s) don't start with a # symbol - then you must describe the FULL named container path back to form level.

For example, if in Form 2, the SerialNo field is actually named &quot;mySerialNo&quot; and it is in a box named &quot;myBox&quot;, and this is on a page which you have named &quot;myPage&quot;, then then notation is :

if not someFrm.myPage.myBox.mySerialNo.locate(&quot;SerialNo&quot;, SerialNo.value) then

The same principle applies for Form1. If The same conditions applied to both Form1 and Form2 then the notation is:

if not someFrm.myPage.myBox.mySerialNo.locate(&quot;SerialNo&quot;, myPage.myBox.mySerialNo.value) then

Get the idea?...Only object names which start with the hash (#) symbol are transparent!

Hope this helps.
 
Thanks again OGriofa,
All your assumtions are correct. SerialNo is a field on each form. It is identified as \#Form1\#Page1\SerialNo .
The first If - Endif loop finds the correct form and opens it on top (when offending loop is rem'd out). But when I put these lines back in I still get &quot;Unknown Identifier&quot;.
I tried the unnecessary (and probably wrong)...
if not someFrm.#Form1.#Page1.SerialNo.locate(&quot;SerialNo.&quot;,#Form1.#Page1.SerialNo.value) then
But this gives &quot;Object Expected&quot; at value.
I shall keep trying but I am a Technical User and not a Programmer.
Thanks again.
 
You don't need to specify objects starting with # in the container path. The problem is that no object named SerialNo is on the form(s). This means that the field is not named SerialNo - one possibility is that there are punctuation characters in the table fieldname - e.g. is the field called &quot;SerialNo&quot;, &quot;SerialNo.&quot; or &quot;Serial No&quot; in the table. Spaces and punctuation characters translate to underscores when the field object is created on the form. There are also other situations which cause the object names to be slighty different.

Open Form1 in design mode. Watch the status line where the selected object is displayed. Initially this is #Form1. Watching the object names in the status bar, slowly mouseclick over the SerialNo field object until it has been it has the hanldes on it. Look at the name of the field in the status line. This is the exact name that should be used. Repeat for Form2. Also check the exact name of the field in the table. You will need this to be exactly correct for the first parameter in the locate() method.

HTH.
 
Thanks OGriofa,
You were absolutely correct. When the four databases and forms were set up (not by me) the field was originally named &quot;Serial No.&quot; , this was changed to &quot;SerialNo&quot; and today I found remnants of the old field name &quot;.&quot; in particular. This has all been sorted and program now runs smoothly, switching between different forms without having to type in the Serial Number for each form.
Thanks for sticking with me!
I'll make a programmer yet (I think not!).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top