If Len(Me.[COLOR="blue"]FieldName[/COLOR]) & vbNullString) = 0 Then
Cancel = True
Msgbox Me.[COLOR="blue"]FieldName [/COLOR]& " is required"
Me.[COLOR="Blue"]FieldName[/COLOR].SetFocus
End If
You can do that in the Before Update event of the Form:
Code:If Len(Me.[COLOR=blue]FieldName[/COLOR]) & vbNullString) = 0 Then Cancel = True Msgbox Me.[COLOR=blue]FieldName [/COLOR]& " is required" Me.[COLOR=Blue]FieldName[/COLOR].SetFocus End If
What does that mean?
Good to know!
I'm sure you'll come back on this thread![]()
Good to know!
I'm sure you'll come back on this thread![]()
Remember that it needs to be written for every required field.
Let me see the full code that you wrote. And I hope you put it in code tags this time!
If Len(Me.Datum_ugovora) & vbNullString = 0 Then
Cancel = True
MsgBox Me.Datum_ugovora & " is required"
Me.Datum_ugovora.SetFocus
End If
If Len(Me.Od_kada_je_kod_nas) & vbNullString = 0 Then
Cancel = True
MsgBox Me.Od_kada_je_kod_nas & " is required"
Me.Od_kada_je_kod_nas.SetFocus
End If
If Len(Me.Do_kada_je_kod_nas) & vbNullString = 0 Then
Cancel = True
MsgBox Me.Do_kada_je_kod_nas & " is required"
Me.Do_kada_je_kod_nas.SetFocus
End If
If Len(Me.Ime_vlasnika_psa) & vbNullString = 0 Then
Cancel = True
MsgBox Me.Ime_vlasnika_psa & " is required"
Me.Ime_vlasnika_psa.SetFocus
End If
If Len(Me.Prezime_vlasnika_psa) & vbNullString = 0 Then
Cancel = True
MsgBox Me.Prezime_vlasnika_psa & " is required"
Me.Prezime_vlasnika_psa.SetFocus
End If
If Len(Me.Cena_po_danu) & vbNullString = 0 Then
Cancel = True
MsgBox Me.Cena_po_danu & " is required"
Me.Cena_po_danu.SetFocus
End If
End Sub
[code\]
[code]
With DoCmd
.RunCommand acCmdSelectRecord
.RunCommand acCmdCopy
.GoToRecord , , acNewRec
Me.AllowEdits = True
.SetWarnings False
.RunCommand acCmdPaste
.SetWarnings True
Me.AllowEdits = False
Me.Datum_ugovora.Value = Null
Me.Od_kada_je_kod_nas.Value = Null
Me.Do_kada_je_kod_nas.Value = Null
Me.Cena_po_danu.Value = Null
Me.[Placeno prilikom prijema].Value = Null
Me.Placeno_prilikom_rezervacije.Value = Null
Me.Osiguranje.Value = Null
Me.Prijem_posle_18h.Value = Null
End With
End Sub
[code\]
The end code tag is wrong, it's [/code]. Copy the code again (unless it won't work) and paste it here the correct way.
If Len(Me.Datum_ugovora) & vbNullString = 0 Then
Cancel = True
MsgBox Me.Datum_ugovora & " is required"
Me.Datum_ugovora.SetFocus
End If
If Len(Me.Od_kada_je_kod_nas) & vbNullString = 0 Then
Cancel = True
MsgBox Me.Od_kada_je_kod_nas & " is required"
Me.Od_kada_je_kod_nas.SetFocus
End If
If Len(Me.Do_kada_je_kod_nas) & vbNullString = 0 Then
Cancel = True
MsgBox Me.Do_kada_je_kod_nas & " is required"
Me.Do_kada_je_kod_nas.SetFocus
End If
If Len(Me.Ime_vlasnika_psa) & vbNullString = 0 Then
Cancel = True
MsgBox Me.Ime_vlasnika_psa & " is required"
Me.Ime_vlasnika_psa.SetFocus
End If
If Len(Me.Prezime_vlasnika_psa) & vbNullString = 0 Then
Cancel = True
MsgBox Me.Prezime_vlasnika_psa & " is required"
Me.Prezime_vlasnika_psa.SetFocus
End If
If Len(Me.Cena_po_danu) & vbNullString = 0 Then
Cancel = True
MsgBox Me.Cena_po_danu & " is required"
Me.Cena_po_danu.SetFocus
End If
End Sub
With DoCmd
.RunCommand acCmdSelectRecord
.RunCommand acCmdCopy
.GoToRecord , , acNewRec
Me.AllowEdits = True
.SetWarnings False
.RunCommand acCmdPaste
.SetWarnings True
Me.AllowEdits = False
Me.Datum_ugovora.Value = Null
Me.Od_kada_je_kod_nas.Value = Null
Me.Do_kada_je_kod_nas.Value = Null
Me.Cena_po_danu.Value = Null
Me.[Placeno prilikom prijema].Value = Null
Me.Placeno_prilikom_rezervacije.Value = Null
Me.Osiguranje.Value = Null
Me.Prijem_posle_18h.Value = Null
End With
End Sub