P8 - making choices from list

P8 - making choices from list

Post by David Bostwi » Sat, 19 Aug 2000 04:00:00



I have a macro that adds a record to a table.  My current macro uses several
InputBoxes to enter the various fields.  One of the fields has 4 possible
values (text), and I want to let the user choose one from a list, to be sure
that the same text is entered no matter who enters the data, because that
text will be used to select a value for another field.  What I'd like is
something like an InputBox, but with the choices listed.  I've looked at
ComboBox and ListBox, but I don't think those do what I want, or at least I
haven't found a way to use them the way I'd like.  I've also looked at the
Choose method, but I don't think that's what I want, either.

My macro experience in P8 consists of the existing macro and some playing
around with methods from the examples.  Any suggestions about how to do this
or where to look?  Thanks.

 
 
 

P8 - making choices from list

Post by Liz » Sat, 19 Aug 2000 04:00:00


David,

I'm not sure what you mean by 'macro' since Paradox 8
doesn't really have anything referred to as macros.
However, I think what you want is to select the field which
you want to be a list, then right click on the field and
select Properties from the pop-up menu, then in the Field
Properties dialog, select 'Combo' from the Display type
drop-down list and click the Apply button.  The field should
now look like a drop-down list.  Then, back in the Field
Properties dialog, click on the Define Values... button and
enter the values you'd like to have in the list.  You could
also populate the list from a table rather than via the
Properties dialog, Define Values button.  If you'd like to
know more about how to do that, let us know.

Please note that what we've done so far doesn't force the
users to use the values in the list, they could type in
something not in the list or a variation of what's in the
list.

If you like, you can attach the following code to the
following events for the field (no changes needed).  This
code will loop through the list as the user types - for
example - they type S and it goes to the first entry that
starts with S.  They type S again and it goes to the second
entry that starts with S, and so on.  After the last entry
starting with S, it goes back to the first entry starting
with S.  Type a different character, and it goes to the
first entry that starts with that character.  This will
prevent them from typing values not in the list.

Field object's var:
Var
  stChar String
  liStart, liMatch LongInt  
  loMatch Logical
endVar

Field object's open:
method open(var eventInfo Event)
  loMatch = False
endMethod

Field object's keyChar:
method keyChar(var eventInfo KeyEvent)
var
  uioList UIObject
  liCounter, liEnd LongInt
  stVal String
endVar

eventInfo.setErrorCode(UserError)

if stChar.isAssigned() then
  if eventInfo.vChar() <> stChar then
    stChar = eventInfo.vChar()
    liStart = 1
  endIf
else
  stChar = eventInfo.vChar()
  liStart = 1
endIf

ignoreCaseInStringCompares(True)
uioList.attach(self.first)
liEnd = uioList.List.Count
for liCounter from liStart to liEnd
  uioList.List.Selection = liCounter
  stVal = uioList.List.Value
  if stVal.match(stChar+"..") then
    self.value = uioList.List.Value
    loMatch = True
    if liStart = 1 then
      liMatch = liCounter
    endIf
    liStart = liCounter+1
    if liStart > liEnd then
      liStart = 1
    endIf
    quitLoop
  endIf
  if liCounter = liEnd then
    if loMatch = True then
      uioList.List.Selection = liMatch
      fldField.value = uioList.List.Value
      liStart = liMatch+1
    else
      liStart = 1
    endIf
  endIf
endFor
ignoreCaseInStringCompares(False)
endMethod

Regards,

Liz
---
Get the lead out before you reply


> I have a macro that adds a record to a table.  My current macro uses several
> InputBoxes to enter the various fields.  One of the fields has 4 possible
> values (text), and I want to let the user choose one from a list, to be sure
> that the same text is entered no matter who enters the data, because that
> text will be used to select a value for another field.  What I'd like is
> something like an InputBox, but with the choices listed.  I've looked at
> ComboBox and ListBox, but I don't think those do what I want, or at least I
> haven't found a way to use them the way I'd like.  I've also looked at the
> Choose method, but I don't think that's what I want, either.

> My macro experience in P8 consists of the existing macro and some playing
> around with methods from the examples.  Any suggestions about how to do this
> or where to look?  Thanks.