 |
|
| Computers Forum Index » Computer - Databases - Filemaker » Search or scroll - alphabetic - technique... |
|
Page 1 of 1 |
|
| Author |
Message |
| Smurf... |
Posted: Mon Nov 02, 2009 4:26 pm |
|
|
|
Guest
|
FM 8.5
I am trying to create a system for scrolling through a list by the
first letter of the first word of a NameCompany field. I have searched
this group for an elegant approach but have yet to find one. Does
anyone have one? A defined button approach is fine. I was thinking
there is a Left text calculation that might apply here but I do not
understand which one nor the rule. Other suggestions are welcome.
Thanks
Matthew |
|
|
| Back to top |
|
|
|
| Ursus... |
Posted: Wed Nov 04, 2009 1:23 am |
|
|
|
Guest
|
Somethinh like:
TableA
NameField
cFirstLetter ( calculated textresult ; left ( NaField ; 1)
TableB
gFirstLetter global textfield
Create a TO TableA:cFirstLetter :: gFirstLetter
On a layout from TableB
Create the gFirstLetter field
Create a portal from the TO and place the NameField inside. Sort on
NameField
Now when you go to browse and enter a first letter you want you will see a
list of all names in the namefield starting with that letter.
Could be made to look very pretty, with buttons and all. But I leave that to
your imagination.
Keep well, Ursus
--
Keep well / Hou je goed
Ursus
"Smurf" <wearesmurfs at (no spam) yahoo.ca> schreef in bericht
news:6c189e04-a5d0-44cd-887e-942529df3e51 at (no spam) n35g2000yqm.googlegroups.com...
Quote: FM 8.5
I am trying to create a system for scrolling through a list by the
first letter of the first word of a NameCompany field. I have searched
this group for an elegant approach but have yet to find one. Does
anyone have one? A defined button approach is fine. I was thinking
there is a Left text calculation that might apply here but I do not
understand which one nor the rule. Other suggestions are welcome.
Thanks
Matthew |
|
|
| Back to top |
|
|
|
| Smurf... |
Posted: Sun Nov 08, 2009 2:26 am |
|
|
|
Guest
|
On Nov 3, 12:23 pm, "Ursus" <ursus.k... at (no spam) ziggo.nl> wrote:
Quote: Somethinh like:
TableA
NameField
cFirstLetter ( calculated textresult ; left ( NaField ; 1)
TableB
gFirstLetter global textfield
Create a TO TableA:cFirstLetter :: gFirstLetter
On a layout from TableB
Create the gFirstLetter field
Create a portal from the TO and place the NameField inside. Sort on
NameField
Now when you go to browse and enter a first letter you want you will see a
list of all names in the namefield starting with that letter.
Could be made to look very pretty, with buttons and all. But I leave that to
your imagination.
Keep well, Ursus
--
Keep well / Hou je goed
Ursus
"Smurf" <wearesmu... at (no spam) yahoo.ca> schreef in berichtnews:6c189e04-a5d0-44cd-887e-942529df3e51 at (no spam) n35g2000yqm.googlegroups.com...
FM 8.5
I am trying to create a system for scrolling through a list by the
first letter of the first word of a NameCompany field. I have searched
this group for an elegant approach but have yet to find one. Does
anyone have one? A defined button approach is fine. I was thinking
there is a Left text calculation that might apply here but I do not
understand which one nor the rule. Other suggestions are welcome.
Thanks
Matthew
Hi Ursus
Thank you for the reply. I am not sure I understand the short-hand. I
think you are suggesting a global / value list. Is this right. Is
there a way to create a button grouping (A-Z) which would select all
NameCompany by first letter?
Regards
Matthew |
|
|
| Back to top |
|
|
|
| Your Name... |
Posted: Mon Nov 09, 2009 6:15 am |
|
|
|
Guest
|
It depends on how the database is designed and you are trying to display the
results of going to each letter, but there are basically three methods to
achieve this.
Whichever method is used, as well as alphabetical letters you may or may not
have to worry about non-standard data. For example, should a company named
“1st Car Sales” be listed under “1” or “F” for “first”?
Luckily FileMaker doesn’t bother about the difference between uppercase and
lowercase letters for any of these methods.
1. LOOPING THROUGH RECORDS
The simplest way is to put alphabetical letter buttons on the Layout. Each
letter button would perform a Script which goes to the first record and then
loops through them until it gets to a Record with a matching first letter
(or the next closest letter if there are no Records for the chosen letter).
For this to work, the Records must first be sorted and you may want ALL the
Records or just the Found Set of Records displayed. Obviously sorting and
looping through LOTS of records will mean this method can be slow.
e.g.
Script for “G” button
Freeze Window
Show All Records
Sort [Field: TextField]
Go to Record [First]
Loop
Exit Loop If [Left(TextField;1) >= “G”]
Go to Record [Next; Exit After Last]
End Loop
In older version of FileMaker you’ll need a separate Script for each letter.
In newer versions you could use a single Script and have the buttons pass a
parameter of the appropriate letter.
The Layout can be set to display the Records in ”View as Form” or “View as
List”.
This method means all the Records are still visible, so users can still
scroll backwards / forwards to the Records for other letters.
The downside is that you need 26 buttons (possibly more if needing to
account for non-standard data). You could get around this by having a Global
Field to hold the letter, user typed or picked from a Pop-Up Menu / List
(see the start of the third method below for defining the Value List), and a
single “Go” button to perform the Script, but the benefit of the individual
buttons is that they can be put in the Header or Footer Part of the Layout
when using View as List, while Fields put here can’t be user-changed.
Another downside when having a lot of Records, the window will automatically
scroll, but the first matching Record will be at the bottom of the window.
You could get around this by adding a few more “Go To Record [Next]”
commands at the end of the Script to scroll the window up, followed by the
same number of “Go To Record [Previous]” commands to get back to the first
correct Record.
2. FINDING RECORDS
Another, faster, way would be to have the Script(s) for the buttons perform
a Find instead of sorting and looping through all the Records, but it would
have just records matching the clicked letter.
First you will need to define a new Calculation Field to hold the first
letter of the TextField data.
i.e.
FirstLetter Calculation, Text Result, Unstored
= Left (TextField; 1)
The Scripts can then perform a Find on this Field for the appropriate
letter. The Found Set of records is then sorted so that the results are
alphabetical.
e.g.
Script for ‘T’ button
Enter Find Mode []
Set Field [FirstLetter; “T”]
Perform Find []
Sort [Field: TextField]
Again, the Layout can be in Form or List views, and the downside is that you
again need 26 buttons (possibly more if needing to account for non-standard
data).
3. PORTAL & RELATIONSHIP
A more sophisticated (and complicated) way is to use a Portal to
automatically display just the Records for the chosen letter, which could be
picked from a Pop-up Menu / List. This would require defining a
Relationship.
First you need to define a new Global Text Field to store the chosen letter
and a Calculation Field to store the first letter of the TextField data.
i.e.
g_ChosenLetter Global, Text
FirstLetter Calculation, Text Result, Unstored
= Left (TextField; 1)
You will also need to define a Value List for the Pop-up Menu / List. This
Value List could be a manually typed list of every letter of the alphabet,
not forgetting to include entries for non-standard data.
i.e.
Alphabet Value List
1
3
A
B
C
D
… etc.
A better option for the Value List would be for it to retrieve it’s values
from the Table’s FirstLetter Field. This way the user can only choose
letters that actually have existing records, plus the required options for
Records with non-standard data will also be included automatically.
i.e.
Alphabet Value List
Value from Field FirstLetter
Put the g_ChosenLetter Field onto the Layout and format it to be a Pop-up
Menu / List using the Alphabet Value List. The Field could be left as a
normally formatted Field if you want users to type a letter themselves, or
formatted as Radio Buttons or Checkboxes (using Checkboxes has the benefit
of allowing multiple letters to be chosen and the Portal displaying Records
with a FirstLetter matching ANY of the checked letters).
Next you need to define a Relationship that uses the g_ChosenLetter Field to
match records with the same data in the FirstLetter Field.
i.e.
rel_ChosenLetterRecords
match records in DataTable
when g_ChosenLetter = DataTable::FirstLetter
sort records by TextField
Lastly you can put a Portal (with a scrollbar) for this Relationship onto
the Layout. Inside the Portal’s first row you can put the Field(s) you want
displayed, making sure they are also coming via the same Relationship. The
Portal will automatically sort the Related Records alphabetically.
Now when the user picks a letter in the g_ChosenLetter Field, the Portal
will automatically update to display the Records for just that letter.
Helpfull Harry ) |
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Mon Dec 07, 2009 6:37 pm
|
|