Search finds wrong record

132 views
Skip to first unread message

Herman Laubscher

unread,
Jan 6, 2024, 4:38:33 AMJan 6
to Sailforms Users
Good day to all and best wishes for the year.  I have a problem in that searching for a record returns the wrong record.  What happens is this:

I use checkboxes in the Children (like "Clients") form to book them for transport in the upcoming weekend. Up to now I had 4 checkboxes: to Home, to School, Both trips and Not on bus.  Now I got rid of the "Both" checkbox to save screen space and also because it was just a duplication of the Home and School options. This created a new problem: I may now have 2 entries if the child books for both trips but I do not want 2 separate entries in the Passengers form. (With duplicate ID's, names, dates etc.)  I solved that by using a "count" field that gets updated by button commands of the checkbox - for a new entry that value will be 0 and then the Passengers form is cleared.  Otherwise it searches for the child's ID and updates that record.  That works fine IF I do the second booking while still on the Bookings form.  

When I go out and update this record later, It always updates the same (wrong) record (but the correct date).  I changed the process to open up an existing layout of the Passengers form  where I could modify a record - add friends going with,  change pickup or drop-off points as well as change the bookings via its own checkboxes, That showed me that it always opens that specific, wrong record.

To be clear: When updating a record in the Passengers form (count >1), it should find the  selected child's ID, update some fields and replace the record. The ID in both forms are key fields.

Hope it makes sense!

Gwyn Richards

unread,
Jan 7, 2024, 11:28:04 AMJan 7
to Sailforms Users
Hi Herman
If you are doing a search when count>1 , if there are more records with the same child's id, it will not not know which to search for. So it should be if count =1. If there are more records of that child perhaps a Process List filtered with the child's id would be the answer to update each of them.
Gwyn

Herman Laubscher

unread,
Jan 9, 2024, 3:25:10 AMJan 9
to Sailforms Users
Hi Gwyn
I have modified the process for a second entry on same child as you suggested.  It first saves a variable with child's ID which then serves as the filter for the passengers form, after which it calls in a list process on the passengers form.  Since it is updating an existing record I do not clear the form.  The list process should simply updates the relevant fields in Passengers and then replaces the entry.
FYI the first entry still uses the checkbox On Change commands to clear the passengers form and add the entries.  It work fine but I want to replace it with a list process once I get it working.
So what happens is this: 
1. I add a first entry for Child A (fetch from school). All fields are correct.
2. I update this entry with the 2nd trip (take to school.) Fields are updated correctly.
3. I add a new entry (for a child in a different school and different bus stop).  There is a new record in Passengers but I found the following errors:
   i) The record with the most correct fields (record 1) has the Parent ID for the 2nd child.
 ii) The 2nd record has the ID of the 1st child; 
iii) and has no Parent ID; 
 iv) and the checkbox for School is cleared;
 v) and the school name is completely wrong but the bus stop is correct;
vi) and the school pickup time is that of the 1st child (wrong for the incorrect school in this record as well as for the child's actual school.)
  
The On Change commands do the following: (If checkbox = true)   **checkboxes in Child form**

If counter = 0 : (new entry) 
1. Change counter to 1, replace entry for Child
2. Clear Passengers.
3. Add the relevant data to fields in Passengers from Child record. Data not in child record is added via Search Form commands.
4. Run a List Process form Parent/Child table to get Parent ID. (This table is an Outer Join table to connect >1 parent to >1 child.)
5. Saves as new entry in Passengers.

If counter = 1: (update existing entry)   ** for taking to school in his example **
1. Change counter to 2; replace entry for Child
2. set var to child ID
3. run list process: Passengers form, filtered on dates for upcoming weekend and child ID

The list process command are:
1. Update School checkbox to true
2. Add data for fields: Bus stop to school, Departure time at bus stop, school drop-off sequence number,  amount due for trip, parent ID.
3. Replace entry.

So the list process  changes the value of School to 1 but it is actually cleared (error 3.iv)
# the bus stop comes from a Search on Children and is correct
# there is a Search on school name in Passengers to get drop-off sequence number but it does not update school name (error 3.v).  How is school name and pickup time changed by itself?
# the Parent ID search source is Children so maybe it should come from child ID in current Passengers entry? (error 3.i and iii)
# there is no command regarding child ID because it is already there. How does it change by itself?

I wonder if I do a new Search, the previous link is probably lost since it now points to a different record? So to get a value from the original search table I will have to do that Search again? That's what I currently do.

Thanks so far.

Herman Laubscher

unread,
Jan 15, 2024, 3:07:54 AMJan 15
to Sailforms Users
I have modified the booking process basically from scratch. I found that whenever I do the first booking no booking is done.  The reason is that the child's ID (counter field) is cleared somewhere at the start and because of that the entry was not done.  Nowhere in the process is the ID modifies - just forced to the Passengers form and towards the end used in a Search Form command.  Now the more baffling part: If I change the ID field to a Number instead of Counter it works perfectly.  Even adding a second booking - adding data to existing record, my problem with the original post - works perfectly. For the last 2 years this field was a counter field and I had no problems booking????   
Reply all
Reply to author
Forward
0 new messages