کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی
کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی

رویداد NotInList کنترل کمبو باکس و رویداد Onchange



این رویداد زمانی رخ می  دهد که کاربر مقداری در قسمت تکست باکس کمبو باکس وارد نماید و آن  در لیست کمبو باکس نباشد.



The NotInList event occurs when the user enters a value in the text box portion of comb box that isn't in the combo box list.

رویداد NotInList زمانی اتفاق می افتد که کاربر مقداری را در قسمت تکست باکس کمبوباکس  وارد نماید  که در لیست کمبو باکس نیست.


Private Sub object_NotInList(NewData As String, Response As Integer)

Object   The name of a combo box control.

نام کنترل کمبو باکس است

NewData   A string that Microsoft Access uses to pass the text the user entered in the text box portion of the combo box to the event procedure.

رشته ای که مایکروسافت اکسس برای پاس دادن متن که کاربر وارد کرده در قسمت تکست باکس کمبو  به رویه رویداد استفاده می شود.

Response   The setting indicates how the NotInList event was handled. The Response argument can be one of the following intrinsic constants:

این تنظیم نشان می دهد چگونه  رویداد NotInList اداره شود.آرگومان Response می تواند یکی از ثابت های زیر باشد.

Constant Description

acDataErrDisplay (Default) Displays the default message to the user. You can use this when you don't want to allow the user to add a new value to the combo box list.

پیش فرض acDataErrDisplay است و پیام پیش فرض را به کاربر نمایش می دهد.می توان زمانی استفاده کرد که کاربر اجازه اضافه کردن مقدار جدید به لیست کمبو نداشته باشد.

acDataErrContinue Doesn't display the default message to the user. You can use this when you want to display a custom message to the user. For example, the event procedure could display a custom dialog box asking if the user wanted to save the new entry. If the response is Yes, the event procedure would add the new entry to the list and set the Response argument to acDataErrAdded. If the response is No, the event procedure would set the Response argument to acDataErrContinue.

acDataErrContinue پیام پیش فرض را به کاربر نمایش نخواهد داد.زمانی استفاده می شود که بخواهید پیام خودتان را به کار نمایش دهید.

acDataErrAdded Doesn't display a message to the user but enables you to add the entry to the combo box list in the NotInList event procedure. After the entry is added, Microsoft Access updates the list by requerying the combo box. Microsoft Access then rechecks the string against the combo box list, and saves the value in the NewData argument in the field the combo box is bound to. If the string is not in the list, then Microsoft Access displays an error message.


acDataErrAdded پیامی به کاربر نمایش نمیدهد اما شما را قادر می سازد که در لیست کمبو باکس داده ای را وارد کنید.بعد از اینکه ورودی اضافه شد مایکروسافت اکسس لیست را با Requery کردن کمبو باکس به روز رسانی می کند. سپس مایکروسافت اکسس دوباره  رشته مقابل لیست کمبو باکس را بررسی می کند و مقدار در آرگومان New Data در فیلدی که باند شده ذخیره می شود.اگر رشته در لیست نباشد مایکروسافت اکسس خطایی را نمایش می دهد.


پس وقتی شما ورودی به تکست باکس کمبو می دهید ( رشته ای وارد می کنید ) مقدار آرگومان New Data می شود ورودی شما می توانید با Dlookup آنرا در جدول و فیلد مورد نظر چک کنید اگر وجود نداشت به کاربر پیام دهید در جدول وجود نداردو undo کنید.


Dlookup(New Data,"نام جدول")



When the LimitToList property is set to Yes and the combo box list is dropped down, Access selects matching values in the list as the user enters characters in the text box portion of the combo box, even if the AutoExpand property is set to No. If the user presses Enter or moves to another control or record, the selected value appears in the combo box. In this case, the NotInList event will not fire. To allow the NotInList event to fire, the user should not drop down the combo box list.


زمانیکه ویژگی LimitToList به Yes تنظیم می شود و لیست کمبو باکس ، Drop Down یا به پائین باز می شود ( لیست کشویی ) اکسس بمحض ورود هر کاراکتر آنرا با لیست انتخاب شو انطباق میدهد حتی اگر ویژگی AutoExpand به No تنظیم شده باشد.( جهت جستجو در خود کمبو باکس AutoExpand را حتما تنظیم کنید و SetFocus هم فراموش نشود ) اگر کاربر کلید Enter را بفشارد و یا به کنترل یا رکورد دیگر برود ( منتقل شود - حرکت کند - مکان نما را به آنجا ببرد ) مقدار وارد شده در کمبو باکس ظاهر می شود. در این مورد رویداد NotInList اجرا نمی شود. برای اجازه دادن به اجرای این رویداد کاربر نبایست لیست کمبو باکس را یه پائین بکشد.


ویژگی Onchange در تکست باکس :


This property is helpful for programmatically changing the action that Microsoft Access takes when an event is triggered. For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

 این ویژگی برای تغییر برنامه ای که مایکروسافت اکسس زمان راه اندازی یک رویداد انجام می دهد مفید است.بعنوان مثلل بین فراخوانی یک رویداد ، ممکن است لازم باشد پارامترهای یک عبارت را تغییر دهید یا بسته به شرایطی که در آن رویداد راه اندازی شده ، از رویه رویداد به عبارت یا ماکرو تغییر دهید.

The Change event occurs when the contents of a text box or the text portion of a combo box changes. It also occurs when you move from one page to another page in a tab control.

رویداد Change زمانی رخ می دهد که محتویات یک تکست باکس یا قسمت تکست کمبو باکس تغییر کند. همچنین زمان حرکت از یک Page به Page دیگر در کنترل تب ( tab control ) .



لطفا نظر سنجی فراموش نشود








عدم نمایش پیام کمبوباکس درصورت مچ نشدن مقدار تکست باکس کمبو با لیست باکس کمبو



♧استفاده از رویداد NotInList کمبو باکس♧



پراپرتی LimitToList حتما باید Yes باشد 


.NotInList (NewDataResponse)

Response=0 Or Response=acDataErrContinue