Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-12

Partially disabling DBNav based on a record set value

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Chris Jennings

Hi All

I have the following column as part of a mySQL table.

`courses_subject_lock` CHAR(1) NOT NULL DEFAULT 'F'

I would like to modify the state of a DBNav component such that some aspects of it are disabled based on a record set value.

Specifically, I would like to disable only the DELETE function if the value for this field in a given recotd is set to T

Any help would be approciated.

Thanks

Chris

Reply by email

JoshyFun
to Chris Jennings

Hello Lazarus-List,

Sunday, December 6, 2009, 7:29:27 PM, you wrote:

CJ> I have the following column as part of a mySQL table. CJ> `courses_subject_lock` CHAR(1) NOT NULL DEFAULT 'F' CJ> I would like to modify the state of a DBNav component such that some CJ> aspects of it are disabled based on a record set value. CJ> Specifically, I would like to disable only the DELETE function if the CJ> value for this field in a given recotd is set to T

In the AfterScroll event of your query enable/disable the navigation buttons manually.

Best regards, JoshyFun

Reply by email

Chris Jennings
to JoshyFun

Hi

Sorry I'm new to Lazarus and my Delphi experience is way in the past. I have spent the last four years in school studying an unrelated topic.

If I code

procedure TfrmSubjects.zqrySubjectsAfterScroll(DataSet: TDataSet);
begin
  DBNavigator1.VisibleButtons := [nbFirst,nbPrior,nbNext,nbLast,nbInsert];
end;

The above button list is displayed as soon as the program loads. I do however get the button list I am after.

I somehow need to be able to wrap this into an IF statement something like

If filed x = y then
procedure TfrmSubjects.zqrySubjectsAfterScroll(DataSet: TDataSet);
begin
  DBNavigator1.VisibleButtons := [nbFirst,nbPrior,nbNext,nbLast,nbInsert];
end;

endif

I am not able to figure out the if statment. I did know how to work with the DBNav buttons display.

JoshyFun wrote 15 lines
Hello Lazarus-List, Sunday, December 6, 2009, 7:29:27 PM, you wrote: CJ> I have the following column as part of a mySQL table. CJ> `courses_subject_lock` CHAR(1) NOT NULL DEFAULT 'F' CJ> I would like to modify the state of a DBNav component such that some CJ> aspects of it are disabled based on a record set value. CJ> Specifically, I would like to disable only the DELETE function if the CJ> value for this field in a given recotd is set to T In the AfterScroll event of your query enable/disable the navigation buttons manually.

Reply by email

JoshyFun
to Chris Jennings

Hello Lazarus-List,

Sunday, December 6, 2009, 8:02:47 PM, you wrote:

CJ> I somehow need to be able to wrap this into an IF statement something like CJ> If filed x = y then
[...]
CJ> I am not able to figure out the if statment. I did know how to work with CJ> the DBNav buttons display.

Something like:

If Dataset.FieldByName('CheckField').AsString='F' then begin
  [.....]Show delete
end else begin
  [.....]Hide delete
end;

In AfterScroll field "fields" points to the current record.

Best regards, JoshyFun

Reply by email