Writing Records

  • Thread starter Thread starter Kristel
  • Start date Start date
K

Kristel

Hi all
I have just started using access and need your asistance.

I generate a unique customer ID using a procedure I
created. How do I insert this ID into the table that
contains the customer record of this new customer. The
newly created customer details is captured on a form and
sent to the table. This ID would be used to reference
future records.

Thanks in anticipation.
Kristel
 
Presumably CustomerID is a field in the table that you're updating with the
rest of the data from your form.

You can use VBA code to assign your computed value to the CustomerID in your
form. The best place to put the code would be in the form's BeforeUpdate
event.
 
Kristel,

I understand your procedure is a function in VB? For the sake of this
example, I'll assume its name to be Generate_Cust_ID(), and the name of the
control on your form that is bound to the customer ID field in your table to
be txtCustID, and you'll need to change to the actual function and control
names. Note: it has to be a function, not a sub!

Use the form's On Current event to fire this small piece of code:

If Me.NewRecord Then
Me.txtCustID = Generate_Cust_ID()
End If

HTH,
Nikos
 
Back
Top