473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Default Value Autoincrement within a Subform

I have a form that has an embedded subform (Datasheet View) that are
linked based on a 1-many ID field. I have a field (SET) in my embedded
subform that I want to Autoincrement starting with 1...and adding 1 to
every new record.

The Autoincrement needs to be separate for each ID. For example when I
go to the form and enter a new record in the main form, the SET field
should start over at 1 as a default and continue (+1) for each new
record in the table that has many records related to the 1 table based
on ID.

My question is separate from Using the Dmax value
(me.SET=nz(dmax("SET","tbl_catch"),0)+1 ) in a table because i want the
autoincrement to start from 1 in the subform with each new record.

How do I do this?

Thanks for your help.

Mike

Jun 22 '06 #1
1 3414
On 22 Jun 2006 12:02:55 -0700, "Mike" <mi***@upperskagit.com> wrote:
I have a form that has an embedded subform (Datasheet View) that are
linked based on a 1-many ID field. I have a field (SET) in my embedded
subform that I want to Autoincrement starting with 1...and adding 1 to
every new record.

The Autoincrement needs to be separate for each ID. For example when I
go to the form and enter a new record in the main form, the SET field
should start over at 1 as a default and continue (+1) for each new
record in the table that has many records related to the 1 table based
on ID.

My question is separate from Using the Dmax value
(me.SET=nz(dmax("SET","tbl_catch"),0)+1 ) in a table because i want the
autoincrement to start from 1 in the subform with each new record.

How do I do this?

Thanks for your help.

Mike


Add a WHERE clause as the third argument of the DMax.

Me.SET=Nz(DMax("SET","tbl_catch","[ID]=Forms!NameOfMainForm!ID"),0)+1

This will provide a separate result for each ID.

I would not be using "SET" as a field name as it is a reserved word in SQL and
may cause conflicts down the line.

Wayne Gillespie
Gosford NSW Australia
Jun 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Terry Bickle | last post by:
Please forgive me for using the wrong term here or there. I'm an old Excel 4 macro guy who didn't convert to VB and I'm tinkering with an Access 2000 DB. I'm sure there is a simple Access 101...
2
by: CSDunn | last post by:
Hello, I have a field called 'TestGrade'in a subform called 'frmSelectByTestSub'that I need to assign a default value to, and the value needs to be an integer value that is exactly the same as the...
0
by: Michael | last post by:
I am trying to create an access database within Net 2003 using the ADOX library which works fine except when I try to add the AutoIncrement property to the ContactId column. I am experiencing a...
5
by: JC Voon | last post by:
Hi: How to reset the autoincrement value generated by DataTable ? I've master and detail table, the detail table has a autoincrement column, each time i add a new master record, i need to...
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
4
by: rczuba | last post by:
Problem: Creating a Default Value for a field in a subform when a field in the subform & form match. I'm trying to create a payroll database for a small home business that I have that has had...
3
by: tmdan | last post by:
This may be very simple but I cant figure it out and it driving me nuts. I have a form with a datasheet as a subform within it. Its is a Quote/Sale form. I have a QuoteItems table and a...
4
by: Whasigga | last post by:
Hi I've created a form that has 7 subforms. It is the same subform, bound to a table, just repeated. This form represents a week, and each subform is used to enter in data for each day of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.