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

Table update question. 2

Status
Not open for further replies.

woodyinoz

IS-IT--Management
Jan 8, 2002
215
0
0
GB
Right here we go.

I have managed to import text files in to a table using some simple script which appends the table everytime a new textfile is available.

My problem is that I want to run 2 dialog boxes which ask for a contract & structure number before sending you to a form which will display the information (which is enertaed by a query) on the selected contract/structure only.
I have managed to do this by storing the search results in a seperate table from the master table. But because of this any ammendments made to the data on the form are not recorded in the master table.

Below is the script which runs my dialog box search:-

method pushButton(var eventInfo Event)
var
strFormName String
fHandle Form
cont4 query
contnum number
strnum number
strReportName string
rHandle report
endvar

contnum = 0
contnum.view("Enter A Contract Number:-")
strnum = 0
strnum.view("Enter A Structure Number:-")

cont4=Query

PartReport.DB | Cont# | Str# | MARK | QUANTITY | SECTION | GRADE |
| Check =~contNum | Check =~strNum | Check P.. | Check | Check | Check |

PartReport.DB | LENGTH | AREA | NHG | Plate ID |
| Check | Check | Check | Check |

EndQuery

If not executeQBE(cont4,"cont4.QBE") then
errorshow()
endif

strFormName = "Chris Examp.fsl"

if NOT fHandle.open(strFormName) then
msgStop("Error opening " + strFormName, "Please make sure the form exists and try again.")
endIf

endMethod

If anybody can suggest where I am going wrong or an alternative way around it please let me know.

Thanks,

Woody.
 
I'm guessing you've set it up so that "Chris Examp.fsl" uses cont4.qbe as it's master table.

It may be easier to use PartReport.DB as the master table, but set filters on the Cont# and Str# fields. That way the form is connected to the required underlying table. If you want to prevent the user editing some fields, then set those field's property to readOnly.

Have a look in help at the following opal methods:
SetFilter(), SetGenFilter(), SetRange()

Caution: Unless indices are used, some of the above have performance issues with large tables.
 
You could use the master table in the form and apply a filter to it.
var
f form
daCriteria dynarray[] anytype
endvar

contnum = 0
contnum.view("Enter A Contract Number:-")
strnum = 0
strnum.view("Enter A Structure Number:-")


daCriteria["Cont#"] = contnum
dacriteria["Str#"] = strnum
daCriteria["MARK"] = "P.."
f.open(""Chris Examp.fsl",winstylehidden)
f.{insert uiobjectname here}.setgenfilter(daCrit)
f.show()
f.bringtotop()

HTH,
Richie

 
Woody,

It looks like you're trying to get the user to enter a couple of values and then use those to locate records in PartReport so they can be updated as needed. Is this correct?

If so, a query isn't your best approach because (by default) query results are saved in a different table.

You could certainly extend your current approach by adding an update option that runs a CHANGETO query to post the edits in your Cont4 results back into PartReport, but perhaps an alternate approach would be better.

First, view() is not really a good user input tool, for it limits you to obtaining one value at a time and doesn't tell you whether or not the user cancelled the dialog.

Instead, create a separate form with two unbound field objects (named fldContractNo and fldStructureNo) and two buttons (btnOK and btnCancel).

Add this code to btnCancel's pushbutton event:

Code:
formReturn( FALSE )

Add this code to btnOK's pushbutton event:

Code:
formReturn( TRUE )

Save your new form. (I'll assume it's called getcsno.fsl.)

Now, revise your current pushbutton code to something along these lines:

Code:
var
   frmGetCSNo  Form
   strContractNo,
   strStructureNo String
endVar

   if not frmGetCSNo.open( "getcsno" ) then
      errorShow( "Can't open getcsno",
                 "Use [>>] for details." );
   else
      if frmGetCSNo.wait() then
         strContractNo = frmGetCSNo.fldContractNo.Value
         strStructureNo = frmGetCSNo.fldStructureNo.Value
         doSomething()
      endIf
      try
         frmGetCSNo.close()
      onFail
         ; do nothing; it's already closed.
      endTry
   endIf

Now, this is only half the battle, the part that gets the user's values. It shows several things, including how to:

1. Create and display a dialog box.
2. Collect values entered by the user.
3. Handle a common problem people run into with dialog boxes.

That last item bears some additional discussion, which can be found at
The best way to solve the second half of your problem depends on what you want to do with the PartReport records that match the values entered by your user.

If you want the user to edit those records, then it may be preferable to either locate matching records or filter the table using the values entered by the user.

ObjectPAL has methods for both, locate() and setGenFilter() respectively. Please note that setGenFilter() is flexible, but slow. I personally prefer ranges instead of filters. They're much faster, but require additional set up in the form of secondary indexes and specific values.

Since this is already a bit long, why don't you clarify what you want to do with the matching ReportReport records and we'll go from there.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top