Everything is right except,
.RecordSource = spDAlias line of code.
You are defining all the columns before assing RecordSource and when you assigns RecordSource it again removes column definition. It should be like this
PROCEDURE (Form1).grdinit
WITH THISFORM
WITH .grid1
.ReadOnly = .F.
.RecordSource = spDAlias
SELE (DAlias)
.ColumnCount=0 && reset
.RecordSourceType = 1 && Alias
.ColumnCount=8
FOR ip = 1 TO 8
ColumnN.Name = XXXX
WITH .XXXX
.ControlSource = (FieldNm)
.Width = YYY
.Text1.Value = VVV
.Text1.Format = FFF
.Header1.Caption = CCC
.ColumnOrder = ip
ENDWITH
NEXT
ENDWITH
ENDWITH
ENDPROC
Bye
Jayesh
>Jayesh - Hi,
>Here's what I do.. Please tell me what I should
>
>(Form1)
>User enters a doc.Number
>Create a tmp table with relevant records from the database
>The tmp table's alias is
>Call the following method.
>When User clicks OK save the data into the database
>Loop back above
>End Form1
>
>
>PROCEDURE (Form1).grdinit
>WITH THISFORM
> WITH .grid1
> .ReadOnly = .F.
> .RecordSource = ''
> SELE (DAlias)
> .ColumnCount=0 && reset
> .RecordSourceType = 1 && Alias
> .ColumnCount=8
> FOR ip = 1 TO 8
> ColumnN.Name = XXXX
> WITH .XXXX
> .ControlSource = (FieldNm)
> .Width = YYY
> .Text1.Value = VVV
> .Text1.Format = FFF
> .Header1.Caption = CCC
> .ColumnOrder = ip
> ENDWITH
> NEXT
> .RecordSource = spDAlias
> ENDWITH
>ENDWITH
>ENDPROC
>
>
>Thanks in advance
>Bye
- Jayesh