Button to make record
Еhere is a table where all clients are written, and in this table there are several more sub tables. We created a button separately from all tables through it we make entries in all tables. But there was a problem in order to make a record in the tables of the client. Now the formula looks like this
let d := Date;
let xCurrRec := Id;
let xNewTime := '.Time.';
let xNew1 := 'Count 1';
let xNew2 := 'Count 2';
let xNew3 := 'Count 3';
What needs to be added in the formula so that the record is sent exactly in the tables of a specific client?
17 replies
-
iliper LTD said:
We created a button separately from all tables through it we make entries in all tables. But there was a problem in order to make a record in the tables of the client.Are you saying that the button is NOT in the Customer table?
-
To make things easier for me to understand can you give me:
1) the table name where the button is in
2) the picture you post is that from the table with the button? if not what is that table name?
3) the name of the reference field between the table with the button and customer table.
4) the name of the reference fields (or subtables) in the customer table.
-
iliper LTD said:
now I have a button and a formula that does everything well, it enters a record in a table 'Cash in/ot'. But this entry is not linked to the visitor's account.Where is this button?
Can you post the code for the button?
-
How is CASH DESK and LIST OF PLAYERS related? Is thE field "Customers", from the original post, the field in CASH DESK? So a record in CASH DESK is linked to only 1 record in Customers (or LIST OF PLAYERS)?
-
In the first picture of your post with the DB you have a field called LIST OF PLAYERS but it is reference field that only allows 1 name. Is that correct?
It seems like you will need to create a third table that links CASH DESK and LIST OF PLAYERS in a N:N relationship. Where many records in CASH DESK are linked to many records in LIST OF PLAYERS.
You said that the button is in the CASH DESK table, but I can't find it. Please let me know where it is or upload a new DB with the button.
-
iliper LTD said:
Yes, probably so, but I'm not a programmer and I don't know how to do it. If you give me a full way how to do it, we will be happy
Fred said:You have done a very good job programming this DB, so you are a programmer.
Looking at your code for the CASH IN button, you clear out the data in the current record in CASH DESK at the end of the code. Is the CASH DESK table more of a dashboard then a data table? In other words, the CASH DESK table is not really supposed to store data but is more of a place for someone to enter in data to be stored in other tables?
So someone is supposed to come to the CASH DESK form. They enter a date, select a Choice, then select a customer, then fill in the number of chips, etc. Then they press the Cash In button. Customer related data gets erased, then they are supposed to select another customer and repeat the process.
-
Fred said:
So someone is supposed to come to the CASH DESK form. They enter a date, select a Choice, then select a customer, then fill in the number of chips, etc. Then they press the Cash In button. Customer related data gets erased, then they are supposed to select another customer and repeat the process.The client approaches the cashier and gives money and receives chips, or gives chips and receives money. The cashier chooses from which floor the client came, casino or slot, and makes an entry. And the record goes to the table 'Cash In/Out'. My problem is that if this is done in the cashier, the record go to the desired table, but without a Date, I don’t know which of the clients did it . Maria helped me, and I can see which client made the exchange. But I'm losing the date. everything is recorded at the earliest date
Fred said:
You have done a very good job programming this DB, so you are a programmer.Thank you for the compliment, but I did everything on the forum, Maria and Fabian) My only idea. Everything was done by the hands of good people who helped me
-
Here is what I changed for the Cash In button:
let xCurrRec := this; let DRselect := (select 'Daily Result')['List of Players' = xCurrRec.'LIST OF PLAYERS' and Date = xCurrRec.Date]; let DRcheck := count(DRselect); let x := dialog("CASH IN", "add new record?", ["No", "Yes"]); if x = "Yes" then switch DRcheck do case 0: ( let newDR := (create 'Daily Result'); newDR.( 'List of Players' := xCurrRec.'LIST OF PLAYERS'; Date := xCurrRec.Date ); let i := (create 'Cash In/Out'); i.( Result := newDR; Date := xCurrRec.Date; 'Cash+/-' := xCurrRec.'.CASH.'; 'USD+/-' := xCurrRec.'.USD.'; 'EU+/-' := xCurrRec.'.EU.'; 'POU+/-' := xCurrRec.'.POU.'; 'VISA+/-' := xCurrRec.'.VISA.'; 'MOMO+/-' := xCurrRec.'.MoMo.'; 'DEPOSIT+/-' := xCurrRec.'.DEPOSIT.'; 'CREDIT+/-' := xCurrRec.'.CREDIT.'; 'Entr+/-' := xCurrRec.'.Entr.'; 'Discount+/-' := xCurrRec.'.Discount.' ) ) default: ( let newDR := first(DRselect); let i := (create 'Cash In/Out'); i.( Result := newDR; Date := xCurrRec.Date; 'Cash+/-' := xCurrRec.'.CASH.'; 'USD+/-' := xCurrRec.'.USD.'; 'EU+/-' := xCurrRec.'.EU.'; 'POU+/-' := xCurrRec.'.POU.'; 'VISA+/-' := xCurrRec.'.VISA.'; 'MOMO+/-' := xCurrRec.'.MoMo.'; 'DEPOSIT+/-' := xCurrRec.'.DEPOSIT.'; 'CREDIT+/-' := xCurrRec.'.CREDIT.'; 'Entr+/-' := xCurrRec.'.Entr.'; 'Discount+/-' := xCurrRec.'.Discount.' ) ) end; '.Time.' := null; '.CASH.' := null; '.USD.' := null; '.EU.' := null; '.POU.' := null; '.VISA.' := null; '.VISA.' := null; '.MoMo.' := null; '.DEPOSIT.' := null; '.CREDIT.' := null; '.Entr.' := null; '.Discount.' := null; 'Count chips 1' := null; 'Count chips 2' := null; 'Count chips 4' := null; 'Count chips 3' := null; 'Count chips 5' := null; 'Count chips 6' := null; 'Count chips 7' := null; 'Count chips 8' := null; 'Count chips 9' := null; 'Count chips 10' := null; 'Count chips Entr' := null; 'Count chips disc' := null; 'LIST OF PLAYERS' := 0 end
Line 1 takes the current record of CASH DESK and puts it in a variable xCurrRec. Now you can skip creating a variable for each field you want to access.
Lines 2 and 3 are added because you don't have a direct relationship between Cash In/Out table and LIST OF PLAYERS. You have to go through Daily Result. Line 2 finds all Daily Result records that match the currently select record in LIST OF PLAYERS and have the same date. Line 3 then counts the results of Line 2.
Lines 4 - 49 is the new code.
Lines 6 - 49 is a switch statement that takes the DRcheck variable and:
Lines 7 - 29 is when the value is 0, it means there isn't already a record in Daily Result that matches the LIST OF PLAYER and the date in the CASH DESK
Lines 9 - 12 creates a new record in Daily Result, sets the LIST OF PLAYERS to match the one selected in CASH DESK, and sets the date to be equal to the one in CASH DESK.
Lines 14 - 29 creates a new record in Cash In/Out, sets reference field Result to be equal to the newly created record in Daily Result. Then it sets all of the other required fields from CASH DESK.
Lines 30 - 46 is what happens when any other value is present in DRcheck. Now we know that there already is a Daily Result record with the selected LIST OF PLAYERS and date.
Line 32 we will use the DRselect variable and get the first record from our selection. There should only be one so it doesn't matter if we use first or last.
Lines 33 - 46 creates a new record in Cash In/Out and links it to the Daily Result record that we have found as well as copy all of the recommended data from CASH DESK.
The remaining lines are the same except I added line 74 to clear the selection from LIST OF PLAYERS, since everything else has been cleared.
So you just need to modify the other buttons with parts of this code.
Content aside
- Status Answered
- 2 yrs agoLast active
- 17Replies
- 206Views
-
2
Following