الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيفية التقيد بعدد محدد من السجلات لايمكن الزيادة عليها

مغلق
بدأه معاوية في 2 أغسطس 2006 · 5 رد · 649 مشاهدة · في قواعد بيانات Microsoft Access
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بسم الله الرحمن الرحيم

السلام عليكم ورحمة الله وبركاته

كيف أضع للسجلات عدد معين بحيث لايمكن إضافة سجلات أخرى عند بلوغ العدد المعين

وبالمثال يتضح المقال :

مثلاً : لنفرض أننا في مدرسة متوسطة ولدينا 3 فصول ...

الصف الأول المتوسط : وعدد استيعابه 20 طالباً .

الصف الثاني المتوسط : وعدد استيعابه 15 طالباً .

الصف الثالث المتوسط : وعدد استيعابه 10 طلاب .

- وضعت جدول للفصول وفيه رقم الفصل واستيعابه

وجدول للطلاب فيه رقم الطالب واسمه وفصله

كما وضعت نموذج لإضافة الطلاب في كل فصل

المشكلة الآن : هي كيف أجعل البرنامج يخبرني أن الفصل ممتلئ ولايمكن قبول طلاب أكثر من ذلك .

ويوجد مثال مرفق لتسهيل المطلوب

مع خالص الشكر والتقدير .

the_students_in_classes.rar

تم تعديل هذه المشاركة بواسطة معاوية في 2 أغسطس 2006 في 00:32

#2

السلام عليكم

اخي معاوية

يخبرك البرنامج عن امتلاء الفصل بواسطة خاصية عدد سجلات الجدول الفرعية التي تخص فصل معين فى حال زيادتها عن العدد اللي تحدده انت

بواسطة الدالة Dcount

وهي دلة عدد السجلات فى جدول بشرط

اي كان الشرط يمكنك تحديده ان شاء الله

مرفق مثال علي الفصل 1 بعد اضافة 5 طلاب ستظهر لك رسالة تفيد ان الفصل ممتلئ

الحدث : بعد تحديث مربع نص اسم الطالب

the_students_in_classes.rar

Microsoft Certified DataBase Administrator MCDBA

#3

شكراً أخي ( ahamied )

- على فكرة أعجبتني عبارة ( حرام كفاية ) :lol:

لكني أريد معرفة معنى هذا الكود أرجو منك أو من أحد المختصين السبر معي حبة حبة كالتالي :

If DCount("*", "student", "Class=1 ") = 5 Then

ما معنى النجممة التي بين علامتي اقتباس

وما معنى رقم 1 في "Class=1 "

ثانياً :

كيف أقيد مدخل البيانات بعدد استيعاب الفصل ، واستيعاب الفصل موجود في جدول Class ، وقد وضعت حقل في النموذج - مصدره هذا الجدول - يبين عدد الطلاب

ثالثاً :

أريد من البرنامج أن يوقف عملية التسجيل ولايمكنك البرنامج من إضافة سجل جديد بعد ذلك - يعني يقفل الإدخال - وهذا اللي أنا قاعد أفكر فيه .

أضفت حقل العدد المتبقي ورفعت البرنامج مرة أخرى أرجو التعديل عليه أو كتابة الكود المناسب مع بيان مكان وضعه

وشكراًً لكلم جميعاً .

the_students_in_classes.rar

#4

السلام عليكم

Dcount تعني عدد السجلات فى جدول معين

* تعني ان عملية العدد التي تقوم بها dcount تشمل جميع سجلات الجدول يمكن ان تقوم بعد سجلات معينة من الجدول مثلا >20 او اي شرط

اذا * تعني شرط كل السجلات

تقوم الان صيغة dcount بعد جميع سجلات الجدول ----------------- هنا وضعنا شرط where

ان تكون قيمة الحقل class فى الجدول = 1

وده شرح ميكروسوفت للدالة

DCount Function

See AlsoApplies ToExampleSpecificsYou can use the DCount function to determine the number of records that are in a specified set of records (a domain). Use the DCount function in Visual Basic, a macro, a query expression, or a calculated control.

For example, you could use the DCount function in a module to return the number of records in an Orders table that correspond to orders placed on a particular date.

DCount(expr, domain, [criteria])

The DCount function has the following arguments.

Argument Description

expr An expression that identifies the field for which you want to count records. It can be a string expression identifying a field in a table or query, or it can be an expression that performs a calculation on data in that field. In expr, you can include the name of a field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function.

domain A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.

criteria An optional string expression used to restrict the range of data on which the DCount function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DCount function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain; otherwise the DCount function returns a Null.

Remarks

Use the DCount function to count the number of records in a domain when you don't need to know their particular values. Although the expr argument can perform a calculation on a field, the DCount function simply tallies the number of records. The value of any calculation performed by expr is unavailable.

Use the DCount function in a calculated control when you need to specify criteria to restrict the range of data on which the function is performed. For example, to display the number of orders to be shipped to California, set the ControlSource property of a text box to the following expression:

=DCount("[OrderID]", "Orders", "[ShipRegion] = 'CA'")

If you simply want to count all records in domain without specifying any restrictions, use the Count function.

Tip

The Count function has been optimized to speed counting of records in queries. Use the Count function in a query expression instead of the DCount function, and set optional criteria to enforce any restrictions on the results. Use the DCount function when you must count records in a domain from within a code module or macro, or in a calculated control.

You can use the DCount function to count the number of records containing a particular field that isn't in the record source on which your form or report is based. For example, you could display the number of orders in the Orders table in a calculated control on a form based on the Products table.

The DCount function doesn't count records that contain Null values in the field referenced by expr unless expr is the asterisk (*) wildcard character. If you use an asterisk, the DCount function calculates the total number of records, including those that contain Null fields. The following example calculates the number of records in an Orders table.

intX = DCount("*", "Orders")

If domain is a table with a primary key, you can also count the total number of records by setting expr to the primary key field, since there will never be a Null in the primary key field.

If expr identifies multiple fields, separate the field names with a concatenation operator, either an ampersand (&) or the addition operator (+). If you use an ampersand to separate the fields, the DCount function returns the number of records containing data in any of the listed fields. If you use the addition operator, the DCount function returns only the number of records containing data in all of the listed fields. The following example demonstrates the effects of each operator when used with a field that contains data in all records (ShipName) and a field that contains no data (ShipRegion).


intX = DCount("[ShipRegion]", "Orders")
intY = DCount("[ShipName] + [ShipRegion]", "Orders")
intZ = DCount("[ShipName] & [ShipRegion]", "Orders")
intW = DCount("[ShipName]", "Orders")

Note The ampersand is the preferred operator for performing string concatenation. You should avoid using the addition operator for anything other than numeric addition, unless you specifically wish to propagate Nulls through an expression.

Unsaved changes to records in domain aren't included when you use this function. If you want the DCount function to be based on the changed values, you must first save the changes by clicking Save Record on the Records menu, moving the focus to another record, or by using the Update method.

Example

The following function returns the number of orders shipped to a specified country after a specified ship date. The domain is an Orders table.


ByVal dteShipDate As Date) As Integer
OrdersCount = DCount("[ShippedDate]", "Orders", _
"[ShipCountry] = '" & strCountry & _
"' AND [ShippedDate] > #" & dteShipDate & "#")
End Function
Public Function OrdersCount(ByVal strCountry As String, _

To call the function, use the following line of code in the Immediate window:

OrdersCount "UK", #1/1/96#

تم تعديل هذه المشاركة بواسطة zahrah في 4 أغسطس 2006 في 15:13

Microsoft Certified DataBase Administrator MCDBA

#5

معلش -- معرفش ليه الانجليزي مش ظاهر بشكل صحيح

تم التعديل

اما عن كيفية تحجيم المدخل

فى المرفق

حاول تدخل اكثر من 5 طلاب فى الفصل 1 ؟

الحدث On Current فى النموزج الفرعي

the_students_in_classes.rar

تم تعديل هذه المشاركة بواسطة zahrah في 4 أغسطس 2006 في 15:15

Microsoft Certified DataBase Administrator MCDBA

#6

معليش عزيزي (ahamied)

بقي علينا نقطة وهي : إيقاف عملية إضافة السجلات بعد العدد المعين ( الموجود طبعاً في جدول الطلاب - حقل الاستيعاب )

أنا لاأريده أن يغلق النموذج أريده فقط أن يلغي الإضافة .

أرجو المشاركة ممن لديه الخبرة .

وبارك الله فيكم جميعاً .

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…