Modification to code repeat the month in Row_Inserted

I want if the month is available, does not complete the entry, and a message appears that the month is already there

This code works, but unfortunately repeats the month
I have more than a thousand records in the same month
Of course, choosing a month from Drop Down
What is required is that if the month is done … it will not be repeated when he chooses another month

This is the code, but it enters all months

// Row Inserting event
function Row_Inserting($rsold, &$rsnew) {
// Enter your code here
// To cancel, set return value to FALSE
$result1 = Execute("

INSERT INTO aihtisab(ID_NO,BOUNS_CODE,month_id)
SELECT reward.ID_NO,reward.BOUNS_CODE,type_month.month_id

FROM reward,type_month

");

return TRUE;
}

I just want to enter the month chosen from the list

Assume the month field name in your current table that related to the “Row_Inserting” server event is “month_id” and its field type is integer or numeric, then try this:

$result1 = Execute("INSERT INTO aihtisab(ID_NO,BOUNS_CODE,month_id)
SELECT reward.ID_NO,reward.BOUNS_CODE,type_month.month_id
FROM reward,type_month
WHERE type_month.month_id = " . $rsnew[“month_id”] . “”);

Thank you very much working successfully

I want now if he wants to enter the month in advance to enter it
I want to refuse to enter the month entered and inform him in the message the month was entered

Please post your latest tables schema that used/related to the code in that “Row_Inserted” server event for more discussion.

Follow the same topic
I want to hide the month from Drop Down
The month whose data was entered as in the code above
So that the month is not repeated twice

Noting that the month is repeated in all records entered

The idea of writing the code … but I don’t know how and where the code is :
if (this.value == “1,2,3,4,5,6,7,8,9,10,11,12”) {
$(this).fields(“month_id”).hide();
} else {
$(this).fields(“month_id”).show();
}
}

The intended months entered do not appear again in the drop-down list

// Row Inserting event
function Row_Inserting($rsold, &$rsnew) {
// Enter your code here
// To cancel, set return value to FALSE
$result1 = Execute("INSERT INTO aihtisab(ID_NO,BOUNS_CODE,month_id)
SELECT reward.ID_NO,reward.BOUNS_CODE,type_month.month_id
FROM reward,type_month
WHERE type_month.month_id = " . $rsnew[“month_id”] . “”);
return TRUE;
}

This code works:

// Lookup Selecting event
function Lookup_Selecting($fld, &$filter) {
//var_dump($fld->Name, $fld->Lookup, $filter); // Uncomment to view the filter
// Enter your code here

if ($fld->Name == “month_id” && (CurrentPageID() == “add” ) ) {
AddFilter($filter, “month_id = ‘1’ || month_id = ‘2’ || month_id = ‘3’ || month_id = ‘4’ || month_id = ‘5’ || month_id = ‘6’ || month_id = ‘7’ || month_id = ‘8’ || month_id = ‘9’ || month_id = ‘10’ || month_id = ‘11’ || month_id = ‘12’”);

}
}

==================================

But i want this code but it is not working:
The month is not equal
Is there a better idea than writing the code this way? Also, the code does not work
// Lookup Selecting event
function Lookup_Selecting($fld, &$filter) {
//var_dump($fld->Name, $fld->Lookup, $filter); // Uncomment to view the filter
// Enter your code here

if ($fld->Name == “month_id” && (CurrentPageID() == “add” ) ) {
AddFilter($filter, “month_id != ‘1’ || month_id != ‘2’ || month_id != ‘3’ || month_id != ‘4’ || month_id != ‘5’ || month_id != ‘6’ || month_id != ‘7’ || month_id != ‘8’ || month_id != ‘9’ || month_id != ‘10’ || month_id != ‘11’ || month_id != ‘12’”);

}
}

I tried this code but it is hidden in either case whether it has value or not
I want if it has a value in the field (month_id ) it hides

// Lookup Selecting event
function Lookup_Selecting($fld, &$filter) {
//var_dump($fld->Name, $fld->Lookup, $filter); // Uncomment to view the filter
// Enter your code here

if ($fld->Name == “month_id” && (CurrentPageID() == “add” || CurrentPageID() == “edit”) ) {
$fld->month_id = FALSE; // *** Disable lookup cache
AddFilter($filter, “month_id != ‘1’”);

}
}