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!

Edit command causes error!

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
I have a form (ProcessQuestionnaire) that prompts the user to enter a key, when the search button is pressed a query is executed that finds the ONE record that matches the criteria and a second form (JurorInformation) opens with DBControls showing the information and allowing updates. I have recently added a button to the JurorInformation form called: Remove from Panel. Following is the code I need to execute when the button is selected:

Code:
procedure TfrmJurorInfo.btnPanelRemoveClick(Sender: TObject);
begin
  With JMSData.qryJurorSearch do
  begin
    Edit;
    FieldValues['PANELID'] := '';
    FieldValues['STATUSCD'] := 'NR';
    Post;
  end;
end;

However when I try to run this, I get an error 'At beginning of table'. I've tried removing the Edit command, but then I get an error that the dataset isn't in Edit or Insert mode.

Any idea what's wrong?

Thanks for any ideas!!

Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
I assume your panel is a table with jurors tied to different events. Are you trying to delete one of the records? Why don't you put a DBNavigator and hide all the buttons except the delete (-) button? Steven van Els
SAvanEls@cq-link.sr
 
How is the query in the ProcessQuestionnaire form carried out?

Is qryJurorSeach a TQuery or a TTable component?

If it is a TQuery then I think you should use an UPDATE SQL command to set the two fields.

Andrew

 
The ProcessQuestionnaire Search button set qryJurorSearch.Active := True;

When the JurorInformation form opens it displays the name, address, status, SSN, etc. All the components on the JurorInformation form are DataControls. I have another process on the JurorInformation form that uses similar code, but works properly, but is a very different situation.

Here is a description of what's going on: I'm not actually trying to delete a record, I'm trying to delete the contents of a field within a record. I assign a panelid to all eligible jurors for a particular date. Once this panelid is generate, the program uses that id to determine if the person needs to be included in other processes. However, after the person has been found eligible and assigned to a panel, they sometimes need to be removed from the panel because they didn't show up for orientation (which means they get postponed to a future date and will recieve a new panelid when they show up at the future date), some need to be removed from the panel and have a new status code entered (prior service or excused for medical reason per doctor's note).

I also thought about using an Update SQL statement, which worked, but then the data on the form wasn't refreshed. If there is a way to update the data and then refresh the fields in the form, that would be a workable solution.

Thanks!

Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Well, you didn't answer the question

Is qryJurorSeach a TQuery or a TTable component?

I'm assuming that it is a TQuery (although Steven assumes it is a TTable).

You could try doing a SELECT statement after the UPDATE statement. That should refresh the DataControls.

Andrew

 
Yes, it's a TQuery component. So you think that I should re-run the query after the update to show the changes? Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Yes, you could re-run the query. It's a crude way of achieving what you want.

A better solution is to use CachedUpdates and the UpdateSQL component.

Your final decision will probably depend on how long it actually takes to do the query and how much time you have to investigate the alternative solution and how comfortable you are with it.

Andrew
 
Ok, I have found that I get the 'At beginning of table' error when I try to change ANY of the Database components. I know it worked before, so I must have changed something. I will have to look over everything and figure it out. I'll let you know what I find. This is really the only thing I have modified so it has to be something I changed recently. Thanks for the input!

Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top