Predmet:Re: Uslov za popunjavanje polja
Na BeforeUpdate forme unesi ovaj kod
PreuzmiIzvorni kôd (Visual Basic):Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim StatusK, Ctl As Control, Frm As Form, Vrijednost
Dim Polje As String
Polje = "Status Kupca"
Set Frm = Me.Form
StatusK = Trim(Me.StatusKupca)
If Format$(StatusK) = "" Then GoTo Kraj
If Me.StatusKupca = 1 Then
Vrijednost = Me.ImeKupca
If Format$(Vrijednost) = "" Then
Polje = Me.ImeKupca.Controls.Item(0).Caption
GoTo Kraj
End If
Else
For Each Ctl In Frm.Controls
If Ctl.ControlType = acTextBox Then
Vrijednost = Ctl
If Format$(Vrijednost) = "" Then
Polje = Ctl.Controls.Item(0).Caption
GoTo Kraj
End If
End If
Next Ctl
End If
Izlaz:
Exit Sub
Kraj:
MsgBox "Unesi " & Polje
Cancel = 1
GoTo Izlaz
End Sub
A ako hoces isprobaj i ovo ostalo:
Samo prekopiraj
PreuzmiIzvorni kôd (Visual Basic):Private Sub Form_Current()
Call StausPolja
End Sub
Private Sub StatusKupca_AfterUpdate()
Call StausPolja
End Sub
Function StausPolja()
Dim StatusK, Ctl As Control, Frm As Form
Dim Kljuc As Boolean, Znak As Boolean
Set Frm = Me.Form
StatusK = Trim(Me.StatusKupca)
If Format$(StatusK) = "" Then
Kljuc = False
Else
Kljuc = True
End If
For Each Ctl In Frm.Controls
If Ctl.ControlType = acTextBox Then
Ctl.Enabled = Kljuc
Znak = Right(Ctl.Controls.Item(0).Caption, 1) = "*"
If Znak = False Then
Ctl.Controls.Item(0).Caption = Ctl.Controls.Item(0).Caption & "*"
End If
If StatusK = "1" Then
If Ctl.Name <> "ImeKupca" Then
Ctl.Controls.Item(0).Caption = Left(Ctl.Controls.Item(0).Caption, Len(Ctl.Controls.Item(0).Caption) - 1)
End If
End If
End If
Next Ctl
End Function
Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.