![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||||
| |||||
|
|
I have a database where there are five different fields containing dates for different things. I want to script a search for a date that may occur in any of these five fields. |
|
I'd love to be able to do this without having to use an extra field that has no bearing on anything else. If anyone has any ideas I'd be very grateful. |
|
What I've done is write two scripts, so I didn't mess up one part whilst trying to get to grips with the other. |
|
The first script says this: [...] Paste [ ] |
|
The script Find export date says this: Show Custom Dialog [ Title: "FindDate"; Message: "Please enter required date"; Buttons: "OK", "Cancel"; Input #1: Purchase Orders::Find date, "Find date" ] |
#3
| |||||
| |||||
|
|
Sara <saramerriman (AT) blueyonder (DOT) co.uk> wrote: I have a database where there are five different fields containing dates for different things. I want to script a search for a date that may occur in any of these five fields. There's a possibility that the database's design is worth re-considering. That's not going to happen. This is an old and much loved database that |
|
I'd love to be able to do this without having to use an extra field that has no bearing on anything else. If anyone has any ideas I'd be very grateful. There's nothing wrong with a field like zzDate_g (global storage) which can be used every time you need a global date field. OK... I've no idea what one of those is at the moment. I shall have a |
|
What I've done is write two scripts, so I didn't mess up one part whilst trying to get to grips with the other. That's good, because you might want to use the scripts for other purposes later. The first script says this: [...] Paste [ ] Don't use copy and paste in scripts (if you want to know why, post that question in a new thread). Hmmm. How else would I search for something then? I can't see a way of |
|
The script Find export date says this: Show Custom Dialog [ Title: "FindDate"; Message: "Please enter required date"; Buttons: "OK", "Cancel"; Input #1: Purchase Orders::Find date, "Find date" ] Use this script in order to fill your global date field. I use a loop and the isvalid function in order to insist on a proper date. Good point. It's only me using it for now, so I'll leave that until (if |
|
The scripts ends with a script result 0 if the user has aborted. Once you have the date in your global date field, a scripted search is easy. |
#4
| |||
| |||
|
|
OK... I've no idea what one of those is at the moment. I shall have a poke around and see what I can find. As I've had to create a new field anyway, is there any reason I can't turn that into a global date field? (When I've worked out what one is, of course). |
|
Hmmm. How else would I search for something then? I can't see a way of getting what I'm looking for into a "Find". |
#5
| |||
| |||
|
|
I'm using FMP 11.0v4 I have a database where there are five different fields containing dates for different things. I want to script a search for a date that may occur in any of these five fields. That's easy enough to do if I enter a date manually in the script editor, but what I'd like to do is add a dialogue box that asks me for the date I want to search for. I've found an inelegant way of doing this using a separate field as somewhere to copy the data from as shown below, but I'm sure there must be a better way. What I've done is write two scripts, so I didn't mess up one part whilst trying to get to grips with the other. The first script says this: Go to Layout [ ³Sara's layout² (Purchase Orders) ] Perform Script [³Find export date² ] Enter Find Mode [ ] Go to Field [ Purchase Orders::Input date L1 ] Paste [ ] [ Select ] New Record/Request Go to Field [ Purchase Orders::Input date L2 ] Paste [ ] [ Select ] New Record/Request Go to Field [ Purchase Orders::Input date L3 ] Paste [ ] [ Select ] New Record/Request Go to Field [ Purchase Orders::Input date L4 ] Paste [ ] [ Select ] New Record/Request Go to Field [ Purchase Orders::Input date L5 ] Commit Records/Requests Perform Find [ ] The script Find export date says this: Show Custom Dialog [ Title: "FindDate"; Message: "Please enter required date"; Buttons: ³OK², ³Cancel²; Input #1: Purchase Orders::Find date, "Find date" ] Go to Field [ Purchase Orders::Find date ] Copy [ ] [ Select ] I'd love to be able to do this without having to use an extra field that has no bearing on anything else. If anyone has any ideas I'd be very grateful. |
)
#6
| |||
| |||
|
|
In article saramerriman-6BA209.10574510062012 (...-september.org>, Sara saramerriman (AT) blueyonder (DOT) co.uk> wrote: I'm using FMP 11.0v4 I have a database where there are five different fields containing dates for different things. I want to script a search for a date that may occur in any of these five fields. That's easy enough to do if I enter a date manually in the script editor, but what I'd like to do is add a dialogue box that asks me for the date I want to search for. I've found an inelegant way of doing this using a separate field as somewhere to copy the data from as shown below, but I'm sure there must be a better way. What I've done is write two scripts, so I didn't mess up one part whilst trying to get to grips with the other. The first script says this: Go to Layout [ ³Sara's layout² (Purchase Orders) ] Perform Script [³Find export date² ] Enter Find Mode [ ] Go to Field [ Purchase Orders::Input date L1 ] Paste [ ] [ Select ] New Record/Request Go to Field [ Purchase Orders::Input date L2 ] Paste [ ] [ Select ] New Record/Request Go to Field [ Purchase Orders::Input date L3 ] Paste [ ] [ Select ] New Record/Request Go to Field [ Purchase Orders::Input date L4 ] Paste [ ] [ Select ] New Record/Request Go to Field [ Purchase Orders::Input date L5 ] Commit Records/Requests Perform Find [ ] The script Find export date says this: Show Custom Dialog [ Title: "FindDate"; Message: "Please enter required date"; Buttons: ³OK², ³Cancel²; Input #1: Purchase Orders::Find date, "Find date" ] Go to Field [ Purchase Orders::Find date ] Copy [ ] [ Select ] I'd love to be able to do this without having to use an extra field that has no bearing on anything else. If anyone has any ideas I'd be very grateful. Don't use Copy and Paste. If the user copies something and then runs your script, they lose whatever they copied and become confused as to why they are now getting a "strange date" when they next perform a paste. The best approach is to use a Global Field or a Variable to obtain the required date from the user, and then use that to set the other fields when in Find Mode. i.e. Set Field [Purchase Orders::Input date L1; g_FindDate] You may need to play with the Get functions that convert the user-entered text in the Global Field to a proper date format, but I think newer versions of FileMaker may be more flexible about this than my old versions. Rather than the necessity of setting multiple fields, you could create a new Calculation Field that hides in the backgorund and combines all the other dates - then you can perform the Find on just one field. Something like: e.g. c_AllDates Calculation, Text Result = GetAsText (Purchase Orders::Input date L1) & "P" & GetAsText (Purchase Orders::Input date L2) & "P" & GetAsText (Purchase Orders::Input date L3) & "P" & GetAsText (Purchase Orders::Input date L4) & "P" & GetAsText (Purchase Orders::Input date L5) where P is the "backwards P" return symbol, and then the script becomes: Enter Find Mode [] Set Field [c_AllDates; GetAsText(g_FindDate)] Perform Find [] Note: I haven't got a copy of FileMaker on this computer, so the "GetAsText" function may not be the correct name. Helpful Harry ) |
![]() |
| Thread Tools | |
| Display Modes | |
| |