HELP: Fw: HELP : Fill Fields automatically on form based on a control's value

  • Thread starter Thread starter Stéphane Vallières
  • Start date Start date
S

Stéphane Vallières

HI Can someone help me

I'm using access 2003 I want to create an invoice and I want some field to
be create automatically.

I want the field lastname and name of the employe to fill out auto when I
enter the employe number

I' ve tried this code

Sub No Employé_onExit (Cancel As Integer)

Dim varNomEmp as Variant

varNomEmp = DLookup("Nom Employé", "employés", "Nom employé =
[Nom employé] ")

if (Not IsNull(varNomEmp))= true Then [Nom employé] = varNomEmp

End Sub



but it's not working...I have no clue of what I'm doing wrong



Thanks in advance

Stéphane

(e-mail address removed) to reply
 
Hi, Stéphane.

Depending upon the way your form is designed, you may use different methods
to fill the fields automatically. See Tom Wickerath's easy, step-by-step
tutorial on finding a record using a combo box on this Web page:

http://www.Access.QBuilt.com/html/find_a_record.html

Or see the tutorial on "How to 'auto-complete' a form, with and without
code" by using an auto-query to automatically fill in information for new
records:

http://www.Access.QBuilt.com/html/forms.html#AutoCompleteForm

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 
HI Can someone help me

I'm using access 2003 I want to create an invoice and I want some field to
be create automatically.

I want the field lastname and name of the employe to fill out auto when I
enter the employe number

I' ve tried this code

Sub No Employé_onExit (Cancel As Integer)

Dim varNomEmp as Variant

varNomEmp = DLookup("Nom Employé", "employés", "Nom employé =
[Nom employé] ")

if (Not IsNull(varNomEmp))= true Then [Nom employé] = varNomEmp

End Sub

If your field name contains a blank you MUST enclose the field name in
square brackets. Also, try using the AfterUpdate event of the [No
Employé control rather than its Exit event. Something like:

Private Sub No_Employé_AfterUpdate()

Dim varNomEmp as Variant

varNomEmp = DLookup("[Nom Employé]", "employés", "[No employé] =
" & Me![No employé] ")

If (Not IsNull(varNomEmp)) Then Me![Nom employé] = varNomEmp
End Sub

I'm assuming that the employee *name* field is [Nom Employé], and that
the employee *number* field is [No Employé] - in your Dlookup as
written, you're returning the employee name when it is equal to the
employee name on the form, a pointless operation!

John W. Vinson[MVP]
(no longer chatting for now)
 
Back
Top