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!

about how to copy optional field

Status
Not open for further replies.

kent01142

Programmer
Sep 26, 2012
26
HK
for right now, i am using this code to copy the header optional fields

For LINECNT = 1 To 13
With adsOEORDHO
.Fields("ORDUNIQ") = adsOEORDH.Fields("ORDUNIQ")
.Fetch
End With

With dsOEORDHO
.RecordClear
.RecordGenerate False

.Fields("ORDUNIQ") = newORDUNIQ
.Fields("OPTFIELD") = adsOEORDHO.Fields("OPTFIELD")
.Fields("VALUE") = adsOEORDHO.Fields("VALUE")
.Fields("TYPE") = adsOEORDHO.Fields("TYPE")
.Fields("LENGTH") = adsOEORDHO.Fields("LENGTH")
.Fields("DECIMALS") = adsOEORDHO.Fields("DECIMALS")
.Fields("ALLOWNULL") = adsOEORDHO.Fields("ALLOWNULL")
.Fields("VALIDATE") = adsOEORDHO.Fields("VALIDATE")
.Fields("SWSET") = adsOEORDHO.Fields("SWSET")
.Insert
End With
Next LINECNT

First time of the copy order would be prefect but after that the fetch would stay in the last fields (WAYBILL), so it is 100% failed...

just wanna ask how can I reset the fetch to run the second time? I tried to use .init but no luck, so is there any other ways to do it?

another question is I tried to copy the detail optional fields in the same logic as well but the VB said i am writing the value into read-only field, so whats wrong with it?

the last question is how can I count how many data within the OEORDHO which belong to the ORDUNIQ? because using 13 is very stupid i think!

Cheers,

Kent
 
1. Why did you open it twice with adsOEORDHO and dsOEORDHO? You only need one view open.
2. You don't update all those fields, you only need OPTFIELD and VALUE. ORDUNIQ is taken care of by the .Composition
3. I don't know about 13 behind stupid, but you're the programmer, you need to figure it out. Maybe you need to take some programming classes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top