bdavewillett
02-08-2002, 06:55 AM
I have a table with 3 fields
[EstimateNo] This is an autonumber
[Supp] This is a number,Long integer
[name] text
The EstimateNo & Supp are primary keys
The numbers run as follows
1/0 [EstimateNo]/[supp]
2/0
3/0
4/0 etc
I need on occasion to create a supplementry Record which would return the original [EstimateNo] but the [Supp] Incremented.
as follows
1/0
2/0
2/1
3/0
4/0
4/1
4/2
4/3 etc.
Do you have any code to support this method or if you can suggest a way of implementing this.
I'm quite new to access so as descriptive as possible ig you can.
Thanks DW
bdavewillett
02-08-2002, 09:14 AM
I,ve changed it slightly please refer to the following.
Firstly thanks Tim K, I am much closer now.
I have two number fields in my database. [EstimateNo] [Supp],Both primary.
The following code does the following.
The first instance copies the record it is on and creates a new one incremented.ie.
1/0
2/0
3/0
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
Me.EstimateNo = Me.EstimateNo + 1
.................................................. ....................
The following copies the [EstimateNo] and adds 1 to the [Supp]
ie.
1/0
1/1
1/2
dependent on which record I am on.
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
Me.supp = Me.supp + 1
.................................................. ....................
Now if I go back on a record and apply the first or second code snippet, I get duplicate errors because the code is trying to copy the current field which already has the next incremented number.
Can the code be changed to:-
(First code snippet)recognise the highest [EstimateNo] whichever record it is on and create the next with the[Supp]field default as 0.
(Second code snippet) copy the current [EstimateNo]keep it as it is,recognise the highest [Supp] number and create the next [Supp]
Its quite easy to understand if you create a test DB with the above code and try it in the middle of a recordset.
I currently select my new records thru an Autokey macro {F3} and would like to try to keep to this format. or I could use the key preview if I knew the keystroke value for {F3}
Dave