Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy fields(data)
Message
From
06/11/2005 07:01:54
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
06/11/2005 06:53:58
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01065805
Message ID:
01065814
Views:
13
I am sorry, I didn't notice that you are copying to a different table.

In this case, you don't need to remember the record position, or the number of records.

Your problem, however, is the following: the USE command closes the source (origin) table, while it opens the destination. You should open both tables, the origin and the destination, before running the SCAN.

A correct loop might be like this (forget about saving recno() and reccount() - that was based on wrong assumptions):
use Table1 in 0
use Table2 in 0
select Table1
scan
  select Table2
  replace;
    Field1 with Table1.Field1,;
    Field2 with Table1.Field2,;
    ...
endscan
Note that you don't need to save all fields to variables; you can access the other table directly. Each table maintains a separate record pointer.

>hi
>i try as under, som thing missing.
>only add one record.
>
>local lnCurrentRecord, lnTotalRecords
>lnTotalRecords = reccount()
>go top
>scan while recno() <= lnTotalRecords && Don't include newly added records
>m.char1=char1
>m.char2=char2
>m.char3=char3
>m.char4=char4
>m.char5=char5
>m.char8=char8
>
>
>  lnCurrentRecord = recno() && remember record position
>use home
>  append blank
>      replace customer_tel WITH m.char8
>      replace home         WITH m.char2
>      replace qdate        WITH m.char3
>      replace name         WITH m.char4
>      replace account      WITH m.char5
>      replace bus          WITH space(10)
>      replace survey_no    WITH space(10)
>      replace list_no      WITH val(m.no)
>      replace flag         WITH 0
>      replace n_try        WITH 0  goto (lnCurrentRecord)  && go back to previous record position
>  ...&& what i must add
>endscan
>
>
>thanks.
>>>hi,
>>>thank you for reply,and advice
>>>
>>>but my code get(append) to new table (home) one record only and exit.
>>>
>>>any idea.
>>>thanks.
>>
>>That is because the APPEND BLANK will go to the end of the table, so there are no more records to process.
>>
>>You can correct this (by remembering the record position and going back to it), you will go into an endless loop, because the newly appended records will also be copied, again and again.
>>
>>If you want to make a duplicate all records, you might do the following changes:
>>
>>
>>local lnCurrentRecord, lnTotalRecords
>>lnTotalRecords = reccount()
>>go top
>>scan while recno() <= lnTotalRecords && Don't include newly added records
>>  ...
>>  lnCurrentRecord = recno() && remember record position
>>  append blank
>>  replace ...
>>  goto (lnCurrentRecord)  && go back to previous record position
>>  ...
>>endscan
>>
>>
>>
>>>>This error means that m.no is not of the expected type. Because of the previous code, m.no is already of type numeric. Just omit the val() function.
>>>>
>>>>On the contrary, I think you have to convert back to character, to save to the field, which seems to be of type character. In this case, you can use the str() function or the transform() function.
>>>>
>>>>>hi all,
>>>>>
>>>>>any idea,help
>>>>>
>>>>>i try to choise fields from mytable to insert it to new table as under,
>>>>>i get error message syntax error
>>>>>
>>>>>USE am2
>>>>>scan
>>>>>m.char1=char1
>>>>>m.char2=char2
>>>>>m.char3=char3
>>>>>m.char4=char4
>>>>>m.char5=char5
>>>>>m.char8=char8
>>>>>
>>>>>
>>>>>       USE home
>>>>>
>>>>>m.no=val(list_no)+1
>>>>>
>>>>>       APPEND blank
>>>>>
>>>>>       replace customer_tel WITH m.char8
>>>>>       replace home         WITH m.char2
>>>>>       replace qdate        WITH m.char3
>>>>>       replace name         WITH m.char4
>>>>>       replace account      WITH m.char5
>>>>>       replace bus          WITH space(10)
>>>>>       replace survey_no    WITH space(10)
>>>>>       replace list_no      WITH val(m.no) && error messageFunction argument value, type, or count is inval
>>>>>       replace flag         WITH 0
>>>>>       replace n_try        WITH 0
>>>>>endscan
>>>>>
>>>>>thanks
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform