Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Radio button - radio group and using combo boxes

Hi there,

We are trying to use a radio group component as a dynamically created object that is to enable us to make a select of one
from three buttons for say 50 people. We are having trouble selecting all buttons, making different selection combination
using the combo boxes and then posting the information to an access table. See details below.

1. Situation
1.1. We have sales representatives (SR) (50-60 SR's) that are required to complete a campaign.
1.2. There are 18 campaigns (Cmp) for the year. There are 10 groups of SR's.
1.3. We have used combo boxes that will 1. Select the year, 2. Select the Cmp (1 to 18). 3. Select the group (1-10). One the
selections are made a button is pressed.
1.4. This brings up on the form, a dynamically created object (radio boxes), showing 3 buttons (button 1 - completed,
button 2 - missed button 3 - suspended), for each of the SR's in that group.
1.5. Only one of the 3 button can be chosen. Once selected press a save button. This information is registered in a database.

2. Problem
We have been able to create the above but cannot do the following:
2.1. Only press one of the three buttons (not be able to select all three buttons).

2.2. If there are 50 SR's how do we do a select all for say, the completed button (or missed button etc), or do a deselect all.
(we can only press one button at a time).

2.3. Once selections have been made, how is this posted this into an access table, as an integer.
2.3.1. We would like the button selection, to show as an integer (say one) to allow for calculations to be perofrmed.
2.3.2. A typical calculation is e.g. So in one year (18 Cmp's) a SR will have completed 10, missed 4, suspended 4 (total 18).
2.3.3. The calculation ill be carried out by an sql query.

2.4. How can you refresh and choose another combo box combination, to then show a different group of SR's.

3. We have used the Radio group component as a dynamically created object.

4. A copy of the code is attached that reflects point 1.
procedure TfrmCampSrep.FormActivate(Sender: TObject);
var
i: integer;
begin
DmAvon1.tblTA.close;
DmAvon1.tblTA.open;
DmAvon1.tblTA.First;
ComboBox1.Items.clear;
while not DmAvon1.tblTA.Eof do
begin
combobox1.Items.Add(inttostr(dmAvon1.tblTa.fieldbyname('TmArId').asinteger));
dmAvon1.tblTA.Next;
end;
DmAvon1.tblTA.close;

for i := 1 to 18 do
begin
ComboBox3.Items.Add(inttostr(i));
end;
ComboBox3.ItemIndex := -1;

DmAvon1.tblCamp.close;
DmAvon1.tblCamp.open;
DmAvon1.tblCamp.First;
ComboBox2.Items.clear;
if dmAvon1.tblCamp.fieldvalues['CmpYr'] = NULL then
begin
dmAvon1.tblCamp.Close;
showmessage('There is no data to show'#13+
'First establish some campaigns in Campaign Setup Screen.');
exit;
end
else
begin
tempyear := dmAvon1.tblCamp.fieldvalues['CmpYr'];
ComboBox2.Items.add(inttostr(tempyear));
while not dmAvon1.tblCamp.Eof do
begin
if dmAvon1.tblCamp.fieldvalues['CmpYr'] <> tempyear then
begin
ComboBox2.Items.add(dmAvon1.tblCamp.fieldvalues['CmpYr']);
tempyear := dmAvon1.tblCamp.fieldvalues['CmpYr'];
dmAvon1.tblCamp.Next;
end
else
begin
dmAvon1.tblCamp.Next;
end;
end;
end;
dmAvon1.tblCamp.Close;

end;

procedure TfrmCampSrep.Button3Click(Sender: TObject);
var
i, x, y: integer;

begin
repsarray := nil;
if ComboBox1.Text = '' then
begin
showmessage('Team Area must be selected');
ComboBox1.SetFocus;
Exit;
end
else
begin
taid := strtoint(comboBox1.text);
end;

if ComboBox2.Text = '' then
begin
showmessage('Campaign Year must be selected');
ComboBox2.SetFocus;
Exit;
end;

if ComboBox3.Text = '' then
begin
showmessage('Campaign Number must be selected');
ComboBox3.SetFocus;
Exit;
end;

x := 390;
y := 130;
rep_count := 0;
i := 1;

while i <> ComponentCount + 1 do
begin
if Components[i].Name = 'RadioGroup' + inttostr(i) then
begin
TRadiogroup(Components[i]).Destroy;
end
else
begin
inc(i);
end;
end;

dmAvon1.SQLCampSrep.Close;
dmAvon1.SQLCampSrep.Parameters.ParamByName('Taid').Value := taid;
dmAvon1.SQLCampSrep.Open;
rep_count := dmAvon1.SQLCampSrep.RecordCount;
SetLength(repsarray, rep_count);
dmAvon1.SQLCampSrep.First;

if rep_count = 0 then
begin
showmessage('No data to display.');
exit;
end;

for i := 0 to rep_count - 1 do
begin
with TRadioGroup.Create(self) do
begin
parent := self;
left := x;
top := y;
width := 300;
height := 41;
columns := 3;
items.add('Completed');
items.add('Missed');
items.add('Suspended');
caption := ' ' + dmAvon1.SQLCampSrep.fieldvalues['SRepFNm'] +
' ' + dmAvon1.SQLCampSrep.fieldvalues['SRepLNm'] + ' ';
color := clMoneyGreen;
end;
repsarray[i] := TRadioGroup(Self);
y := y + 48;
dmAvon1.SQLCampSrep.next;
end;
dmAvon1.SQLCampSrep.close;
end;

procedure TfrmCampSrep.Button2Click(Sender: TObject);
begin
frmMainMenu.show;
frmCampSrep.close;
frmCampSrep.release;
frmCampSrep := nil;
end;

end.



Comments

  • Shawn CarterShawn Carter Member Posts: 0

    _____ | http://forcoder.org | free video tutorials and ebooks about { Go, Visual Basic .NET, Python, Ruby, C#, Assembly, Perl, Objective-C, C, PHP, JavaScript, Swift, C++, Delphi, Scratch, Visual Basic, Java, R, MATLAB, PL/SQL FoxPro, Dart, Bash, ABAP, Julia, Scala, Apex, Clojure, ML, COBOL, Transact-SQL, Rust, VBScript, Hack, D, Lisp, Fortran, Scheme, SAS, Logo, Kotlin, LabVIEW, Awk, Alice, Ada, Erlang, Lua, Prolog, F#, Crystal }

Sign In or Register to comment.