Skip to main content

AccessTr.neT


Access Class Textbox Change Olayı Örnek Uygulama

Access Class Textbox Change Olayı Örnek Uygulama

#13
Dosyadaki  Metin13 textboxuna veri girmek için alttaki gibi yeterli.


Private Sub ClassTextBox_Change()

    Forms("Form1").Controls("Metin13") = Empty
    Forms("Form1").Controls("Metin13") = ClassTextBox.Text
   
End Sub
Cevapla
#14
form adını ve control adını class a argument olarak nasıl gönderebiliriz yani class form1 den ve metin13 den bağımsız olsun
Cevapla
#15
Accesman ve berduş hocalarım sizin için gif hazırladım mantığı anlamanız için.
Set ClassTextBox = TextBox bunlardan fazla yazmışım Img-grin

Public Sub Initialize(TextBox As Access.TextBox)
    Set ClassTextBox = TextBox
    ClassTextBox.OnMouseDown = olayTextBox
    ClassTextBox.OnKeyDown = olayTextBox
    ClassTextBox.OnClick = olayTextBox
   
End Su
b

[Resim: MTVlNzc5ZDk3ZDlhNmM.gif]
Cevapla
#16
(22/03/2020, 20:07)accessman yazdı: form adını ve control adını class a argument olarak nasıl gönderebiliriz yani class form1 den ve metin13 den bağımsız olsun
Birinci yöntem alttaki kodlar gibi property olarak yapılabilir.

Kod:
Public Property Get formad() As Variant
      FormAdi = pFormad
End Property

Public Property Let formad(ByVal FormAdi As Variant)
    pFormad = FormAdi
End Property

Kod:
olay.formad = "Form1"
Dim pFormad
For Each kontrol In Forms(pFormad)

Yukardaki kodlar eklendi.


Kod:
Option Compare Database

Private Const olayTextBox  As String = "[Event Procedure]"

Private WithEvents ClassTextBox As Access.TextBox
Dim pFormad

Public Sub Initialize(TextBox As Access.TextBox)
    Set ClassTextBox = TextBox
    ClassTextBox.OnChange = olayTextBox
End Sub


Public Sub Terminate()
    Set ClassTextBox = Nothing
End Sub


    Private Sub ClassTextBox_Change()
   
        Dim kontrol As Control
        Dim aa
       
        aa = vbNullString
       
        For Each kontrol In Forms(pFormad)
            If kontrol.ControlType = acTextBox Then
                If kontrol.Tag = "xx" Then
                    kontrol.Application.RunCommand acCmdSave
                    aa = aa & "," & kontrol
                End If
            End If
        Next
                                   
       
        aa = Mid(aa, 2)
        Forms("Form1").Controls("Metin13") = Empty
        Forms("Form1").Controls("Metin13") = aa
                If Len(ClassTextBox) > 0 Then
            ClassTextBox.SelStart = Len(ClassTextBox)
        Else
            ClassTextBox.SelStart = 1
        End If
      If Forms("Form1").Controls("Metin13") = ",,," Then Forms("Form1").Controls("Metin13") = Empty
    End Sub


Public Property Get formad() As Variant
      FormAdi = pFormad
End Property

Public Property Let formad(ByVal FormAdi As Variant)
    pFormad = FormAdi
End Property


Kod:
Private Sub Form_Load()

    Dim olay  As New ClassTextboxSec
    Dim kontrol As Access.Control
   
    Set olay = New ClassTextboxSec
    olay.formad = "Form1"
    Set KontrolCollection = New Collection

    For Each kontrol In Me.Controls
        If kontrol.ControlType = acTextBox Then
            If kontrol.Tag = "xx" Then
                Set olay = New ClassTextboxSec
                olay.Initialize kontrol
                KontrolCollection.Add olay, kontrol.name
            End If
        End If
    Next
   
    Set olay = Nothing
    Set Control = Nothing

End Sub

Cevapla
#17
(22/03/2020, 20:07)accessman yazdı: form adını ve control adını class a argument olarak nasıl gönderebiliriz yani class form1 den ve metin13 den bağımsız olsun
ikinci öntem;

Private Sub Form_Load() içindeki
olay.Initialize kontrol yerine olay.Initialize kontrol, "Form1"


ve class kodundaki ilgili yerleride alttaki gibi değiştirin.

Public Sub Initialize(TextBox As Access.TextBox, formAd As String)
    Set ClassTextBox = TextBox
    ClassTextBox.OnChange = olayTextBox
    FormAdi = formAd
End Sub



For Each kontrol In Forms(FormAdi)

Tabii class içindeki If Forms("Form1") olanlarıda If Forms(FormAdi) gibi yapabilirsiniz.
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da
Task