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

relationships

Status
Not open for further replies.

AlastairOz

Technical User
Jul 27, 2010
81
AU
I have a form with a grid and text boxes to enter the data.
When a new record is added, the new line appears in the grid below all the other records,
but when I type into the text boxes, the data appears in the top row of the grid, not in the new record.
 
I suggest you not to use the table itself for the grid. Instead use an SQL recordsource for it. ie:
*Grid.init (might use properties sheet too)
Code:
with this
  .RecordSourceType = 4
  .RecordSource = "select * from myTable into cursor crsGrid"
endwith

*Grid.Afterrowcolchange
Code:
lparameters nIndex
if (this.RowColChange%2 = 1) && row changed
  =seek(crsGrid.KeyField,'myTable','PrimTag')
  this.parent.Refresh
endif

*When new record added
Code:
with thisform.myGrid
  .RecordSource = .RecordSource
endwith

Cetin Basoz
MS Foxpro MVP, MCP
 
Alastair,

After adding the new record, you need to move the record pointer to the record that you just added.

I'm assuming the textboxes have a ControlSource into the underlying table. If so, the edits will go into whichever record in that table is currently the one the record pointer is pointing to. The grid will then reflect the edits to that record.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Think of your related tables like this...

ParentTable ChildTable
A B C A 4 Y Z
A R 1 T
A M N 6
D X Y D 1 A 3
D X 2 C

When your record pointer is pointing to the Parent table it, by default, 'sees' through to the first related record in the Child table.

In order to implement a change to a different Child table record you will have to move the Child table record pointer to a different related record.

As Mike indicated above, adding a new related record into the Child table just adds another record (below the previous records) which can be accessed but is not usually the first related record.

Good Luck,
JRB-Bldr

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top