Line Numbers in subform

J

Julie

I have a subform that I would like to auto generate line numbers.

The parent form is called "frm_Main Storage Entry" and the parent link
field is called "main_SKU-Barcode"
The subform is called "subfrm_DeptsStorage" and the child link field
is called "depts_SKU-Barcode"

The line number field is called "depts_LineNo" and the table it is
stored from is "tbl_DeptsStorage"

I am not an expert access programmer and can't get the line numbers to
auto number properly when scrolling from the parent form. Can someone
help me.
 
T

tina

if i understand correctly, you want to automatically number each record that
you enter into a subform - i'm assuming 1, 2, 3, 4 etc, and begin numbering
from 1, for each "set" of child records that are related to a given parent
record.

you can add code to the subform's BeforeUpdate event, as

If IsNull(Me!depts_LineNo) Then
Me!depts_LineNo = DMax("depts_LineNo", _
"tbl_DeptsStorage","[depts_SKU-Barcode] = " _
Me![depts_SKU-Barcode]) + 1
End If

the above code assumes that the RecordSource of subfrm_DeptsStorage is
tbl_DeptsStorage. also, fyi, recommend you don't use special characters in
anything *you* name in Access (tables, fields, queries, forms, controls,
etc, etc, etc); use alpha characters, numeric characters (but not at the
beginning of a name), and underscore ( _ ) only.

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top