0

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

null
    • Fred
    • 1 yr ago
    • Reported - view
      • iliper LTD
      • iliper_LTD
      • 1 yr ago
      • Reported - view

      Fred Buttons is out to Customer table. It is in a separate table, it is linked to the table of Customers

    • Fred
    • 1 yr ago
    • Reported - view

    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
      • iliper_LTD
      • 1 yr ago
      • Reported - view

      Fred Button is on table 'CASH DESK' and record have to go in table 'List of Players' subtable 'Cash in/out'

      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. And we can't tell who made the purchase. Therefore, we have added to all the fields a field where the name of the account to which the purchase will be recorded should be displayed.

      • iliper LTD
      • iliper_LTD
      • 1 yr ago
      • Reported - view

      iliper LTD 

      this is a photo of the visitor's account, and each visitor has his own account. And when the cashier accepts payment, he went into the account 'LIST of PLAYERS' and filed an entry in 'DAILY RESULT' and 'Cash In/Out' table recorded. We want to simplify this way and make a button in the cashier's table. 

      Here is the photo of the final path where the record should come.

    • Fred
    • 1 yr ago
    • Reported - view
      • iliper LTD
      • iliper_LTD
      • 1 yr ago
      • Reported - view

      Fred will send private message 

    • Fred
    • 1 yr ago
    • Reported - view

    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)?

    • Fred
    • 1 yr ago
    • Reported - view

    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.

    • Fred
    • 1 yr ago
    • Reported - view
    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.

    • iliper LTD
    • iliper_LTD
    • 1 yr ago
    • Reported - view
    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 

    • Fred
    • 1 yr ago
    • Reported - view

    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.

      • iliper LTD
      • iliper_LTD
      • 1 yr ago
      • Reported - view

      Fred Thank you for your time. 2, 11 and 74 line gives an error

      • Fred
      • 1 yr ago
      • Reported - view

      iliper LTD it is the name of field in CASH DESK that points to List of Players. That is the name in your sample DB, you need to match the name in your version if that is not the name. Could it be Customers?

      • iliper LTD
      • iliper_LTD
      • 1 yr ago
      • Reported - view

      Fred You did a miracle, it works properly. 

      • Fred
      • 1 yr ago
      • Reported - view

      iliper LTD That is very nice of you to say, but a miracle it is not. I’m glad it is working for you.

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 17Replies
  • 185Views
  • 2 Following