mugs > det virker ikke dit eksempel terry > Jeg har sat min kode ind på min underformular - BEFORE UPDATE. men det virker ikke..? hvordan får jeg den til at sætte fokus osv. fra min underformular til min hovedformular
Private Sub Firmanavn_LostFocus() If IsEmpty(Me.Firmanavn) Then MsgBox "Du Skal Skrive et Firmanavn" Me.Firmanavn.SetFocus End If End Sub
The form AFTER UPDATE event occurs only when you have altered data or inserted a new record, it doesnt occur when you move from the field Firmanavn to another control.
So you will VERY likely need to have code in more than one event. For example when you INSERT a new record you will need to check that your fields are valid BEFORE the record gets written to the dB (Forms BEFORE update) but just because the cursor is in the fields firmanavn and you move from it (lost focus) you can not be sure that you have altered the record. So there may be no need to inform the user that it needs entering.
You can check the forms dirty property to see if the record has changed.
woodgaard -> Min kode er ikke afprøvet, men burde fungere. Fejlen er, at du ikke fra starten har angivet, at det drejer sig om en underformular. Hvis du står i en formular og vil checke et felt i en undeformular, er du nødt til først (som hubs angiver), at sætte fokus først på underformularen og dernæst på det pågældende felt i underformularen.
Den anden vej fra underformular til hovedformular, kan du nøjes med at sætte fokus på hovedformularen, så vil markøren gå til det første tabulatorindeks i hovedformularen.
Så moralen er: Husk altid at angive, at det drejer sig om en underformular.
If the user is in a field, be it on a the main form OR a sub form, then as long as the focus doesnt move FROM the sub form TO the main form then there should be NO REASON to set focus back to the sub form!
If we are in a detail record and the last field in the detail (tabe order not visual) is Firmanavn then losing focus will move to the next record unless we have set the forms cycle property to current record
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.