Hi. I fear I am about to betray my newbie status...
I have a DBF table. I use it to manually populate a TListBox. I would like the user to click on a name in the list and click an edit button, which then throws up an edit box to allow them to change the name, then repost it to the database.
Here's the code at the moment.
begin
if UsersList.ItemIndex=-1 then Exit;
if not UsersTable.Locate('NAME',UsersList.Items[UsersList.ItemIndex],[]) then
begin
MessageDlg('Error 103',mtError,[mbOK],0);
Exit;
end;
EditName:=UsersTableName.Text;
repeat
if not InputQuery('Edit user', 'Re-enter the user''s name',EditName) then Exit;
until EditName<>'';
UsersTable.Edit;
UsersTableName.Text:=EditName;
UsersTable.Post;
BuildUsersList;
end;
I don't get error 103. The name in the InputQuery is correct. BuildUsersList is my own routine to repopulate the list. But when finished editing and click OK, the last record in the database is the one edited and posted, regardless of the name selected in the list.
I hope that makes sense. Any direction gratefully received.
Jon