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

the button code does not work with the first register

Status
Not open for further replies.

fanlinux90

Programmer
Oct 31, 2022
22
CO
This is the code of the init of the form

Code:
if !used if !used ("supplier_temp")
    SELECT supplier

      afields(structure)

    CREATE cursor supplier_temp from array structure

else

     SELECT supplier_temp
         for re = 1 to reccount()
           SELECT supplier_temp
           go re
           _id = supplier_temp.id
           _name = supplier_temp.name
           _dir = supplier_temp.dir
           _cel = supplier_temp.cellphon
          _em = supplier_temp.email
     scan
     update provider set name=_name, address=_dir, cell=_cel, email = _em where control = 1 and id = _id
     end scan
         end for
    delete all

endif

     SELECT supplier_temp

       APPEND FROM supplier for dispatched = 1

      GO TOP

     Thisform.Suppliers.RecordSource = "supplier_temp"

     Thisform.Suppliers.column1.ControlSource = "supplier_temp.name"

     Thisform.Proveedores.column2.ControlSource = "supplier_temp.direntre"

     Thisform.Proveedores.column3.ControlSource = "provider_temp.cellphon"

      Thisform.Suppliers.column4.ControlSource = "supplier_temp.email"
This is the code for the process button
Code:
     select supplier_temp
       go top
     replace supplier_temp.control with 2
        locate for supplier_temp.control = 2
          REPLACE supplier.control WITH supplier_temp.control for supplier.id = supplier_temp.control
but it does not work with the first record, with the other records if the button code works and changes the control field to 2
 
Once again we have to tell you that it is not the purpose of the forum to debug your code. If you just dump some code in the forum post and expect us to figure out what you are trying to achieve, you will get the sort of response that Chris has just given.

If your code doesn't do what you expect, study it carefully and and work out exactly what it is doing. If that doesn't help, run it in the Trace window, and check that the result of each statement is what you expect. If you resort to posting here, start by telling us exactly what you are trying to achieve. Remember, we don't know anything about your application, the environment it's running in, the data structures, etc.

When you explain the problem, try to use clear English. For example, the sentence "with the other records if the button code works and changes the control field to 2" makes no sense.

And when posting code, using [tt]
Code:
[/tt] tags or the "Code" button on the toolbar will make it considerably easier for us to understand.

To pick up a couple of specific points, your first line reads [tt]if !used if !used ("supplier_temp")[/tt]. Presumably that's a typing error. Are there any other typing errors in this code? Similarly, in the line [tt]for re = 1 to count()[/tt], there is no native function named count(). Is this a function you have defined yourself, or is it another typing error (perhaps you meant RECCOUNT())?

I don't want to discourage you for seeking help here, but you have to make it easier for us to give that help.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

[url=http://www.ml-consult.co.uk/foxstuff.htm]Visual FoxPro articles, tips and downloads[/url]
 
From what I'Ve seen, it's working on problems in details and expecting to enhance the overall system.

Let me assume something, fanlinux90. You have a legacy application, and it falls apart. In the sense that whatever bug you adress and fix, two more come up.
By posting to forums you take advice from experts, so one day it must all come together and work.

You don't see the big picture.
The-Blind-Men-and-the-Elephant_bldmaq.png


And you give nobody the chance to see the big picture, too. To at least have the possibility to be enabled to give good advice about how to bring all this up to a level of maintainability.

It's just not helpful to help you with any detail. All you'll end up with, if you actually make code changes, is a Frankenstein elephant.
Stop posting.

Chriss
 
excuse my mistake mike lewis in writing it's not count, it's reccount() . I already fixed the code to make it more readable
 
the value that is changed when pressing the process button of the selected record
in the cursor supplier_tmp.control is 2 but that record is not copied to the table supplier
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top