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

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

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

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

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

Loops - For Each



Sub forEachExit()
    Dim element As Variant
    Dim animals(0 To 5) As String
    'We have created an array that can hold 6 elements
    
    animals(0) = "Dog"
    animals(1) = "Cat"
    animals(4) = "Snake"
    animals(2) = "Bird"
    animals(3) = "Buffalo"
    'Here we fill each element of the array
    animals(5) = "Duck-billed Platypus"
         For Each element In animals
        'print each element to the immediate window
    'iterates over the animals collection
             Debug.Print element     
End Sub
        If element = "Buffalo" Then Exit For
        'if, at any point, the element becomes equal
             Next

The output to the immediate window will be (we exited the loop before all items could be printed):

Dog
Cat
Bird
Buffalo



Dim MyArray() As String

ReDim Preserve MyArray(2)



Public Function HadleOpenForms()

Dim arr() As String

Redim Preserve arr(Forms.Count)

If forms.Count Then

For i=0 To Forms.Count-1

quotation-marks-in-string-expressions

Arr(i)="" & Forms(i).Name & ""

x=x & iif(x="",",","") & Arr(i)

Next

Debug.Print x

Else 

Exit Function

End If

End Function


تابع بالا را تست کنید چنانچه باید اصلاح شود در نظرات این یادداشت قید کنید و اگر درست است زمانیکه فرم هایتان بصورت Tabbed Document باز است اجرا و نتیجه را در نظرات کپی کنید ( در پنجره immidate window محیط vba اکسس اگر تابع درست عمل کند و خطا ندهد  ، چاپ میشود)



dim intx as integer
dim intCount as integer
intCount = Forms.count-1
for intX= intCount to 0 step -1
docmd.close acform,forms(intX).name
next



Arr=Array("...","....","....")


CountOpenFrms = Application.Forms.Count


SysCmd شامل Action و دوتا آرگومان است کد زیر
مقدار عددی را برمی گرداند که مشخص میکند Object 
باز است یا بسته و یا .....

ObjState = SysCmd(acSysCmdGetObjectState, _
    Application.CurrentObjectType, _
    Application.CurrentObjectName)


vba/api/access.acsyscmdaction












نظرات 0 + ارسال نظر
برای نمایش آواتار خود در این وبلاگ در سایت Gravatar.com ثبت نام کنید. (راهنما)
ایمیل شما بعد از ثبت نمایش داده نخواهد شد