473,405 Members | 2,445 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,405 software developers and data experts.

RE-NUMBER KEYS WHEN NEW KEY ADDED

This is an interesting one.....

I have a field on FORM!FORMDATA (no, I did not name this) called KEY.

There can be multiple KEYS per record (equates to FIELDS on a given
DOCUMENT).

The users want to Add a Key and manually assign the number, say 2.
They do this to retain the order in which fields will print on a
document.

If Keys 2 --- 10 already exist, then Old Key 2 becomes 3, Old Key 3
becomes 4, etc.

Adding a new key is triggered by a button running this code:

Private Sub butAddNew_Click()

On Error GoTo Err_butAddNew_Click

Dim DOCNUMBER As String
Dim SegmentNumber As String
Dim NextKey As Long, Dummy
DOCNUMBER = Form_Number
'DoCmd DoMenuItem 0, 0, 4, 0, A_MENU_VER20 ' Tries to Save
Record
NextKey = GetNextKey(Val(DOCNUMBER))
DoCmd.GoToRecord , , A_NEWREC
Form_Number = DOCNUMBER
'KEY value now on Subform -- aww 8/14/04
Forms![sfrmKeys_AW]![KEY] = NextKey
Forms![sfrmKeys_AW]![KEY].SetFocus

Exit_butAddNew_Click:
Exit Sub

DoCmd.SetWarnings (WarningsOn)

Err_butAddNew_Click:
MsgBox Error$
Resume Exit_butAddNew_Click

End Sub
===

Any idea on how to renumber Keys as described above?

Thanks!

amy
==
Nov 13 '05 #1
2 1249
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I believe it would be better to just set the new key to the last old
key, plus one. E.g.:

key = dmax("key","table_name") + 1

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQR1lrIechKqOuFEgEQLXfQCgoUa6MYeIbNlEi08KGtUIy6 PJwj8An033
fJEcja0dRSnyTC7MpMwG9WjN
=Xfnl
-----END PGP SIGNATURE-----
amywolfie wrote:
This is an interesting one.....

I have a field on FORM!FORMDATA (no, I did not name this) called KEY.

There can be multiple KEYS per record (equates to FIELDS on a given
DOCUMENT).

The users want to Add a Key and manually assign the number, say 2.
They do this to retain the order in which fields will print on a
document.

If Keys 2 --- 10 already exist, then Old Key 2 becomes 3, Old Key 3
becomes 4, etc.

Adding a new key is triggered by a button running this code:

Private Sub butAddNew_Click()

On Error GoTo Err_butAddNew_Click

Dim DOCNUMBER As String
Dim SegmentNumber As String
Dim NextKey As Long, Dummy
DOCNUMBER = Form_Number
'DoCmd DoMenuItem 0, 0, 4, 0, A_MENU_VER20 ' Tries to Save
Record
NextKey = GetNextKey(Val(DOCNUMBER))
DoCmd.GoToRecord , , A_NEWREC
Form_Number = DOCNUMBER
'KEY value now on Subform -- aww 8/14/04
Forms![sfrmKeys_AW]![KEY] = NextKey
Forms![sfrmKeys_AW]![KEY].SetFocus

Exit_butAddNew_Click:
Exit Sub

DoCmd.SetWarnings (WarningsOn)

Err_butAddNew_Click:
MsgBox Error$
Resume Exit_butAddNew_Click

End Sub
===

Any idea on how to renumber Keys as described above?

Thanks!

amy
==


Nov 13 '05 #2
Unfortunately, that won't work, based on the user requirements.

amy
===

MGFoster <me@privacy.com> wrote in message news:<PA*****************@newsread1.news.pas.earth link.net>...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I believe it would be better to just set the new key to the last old
key, plus one. E.g.:

key = dmax("key","table_name") + 1

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQR1lrIechKqOuFEgEQLXfQCgoUa6MYeIbNlEi08KGtUIy6 PJwj8An033
fJEcja0dRSnyTC7MpMwG9WjN
=Xfnl
-----END PGP SIGNATURE-----
amywolfie wrote:
This is an interesting one.....

I have a field on FORM!FORMDATA (no, I did not name this) called KEY.

There can be multiple KEYS per record (equates to FIELDS on a given
DOCUMENT).

The users want to Add a Key and manually assign the number, say 2.
They do this to retain the order in which fields will print on a
document.

If Keys 2 --- 10 already exist, then Old Key 2 becomes 3, Old Key 3
becomes 4, etc.

Adding a new key is triggered by a button running this code:

Private Sub butAddNew_Click()

On Error GoTo Err_butAddNew_Click

Dim DOCNUMBER As String
Dim SegmentNumber As String
Dim NextKey As Long, Dummy
DOCNUMBER = Form_Number
'DoCmd DoMenuItem 0, 0, 4, 0, A_MENU_VER20 ' Tries to Save
Record
NextKey = GetNextKey(Val(DOCNUMBER))
DoCmd.GoToRecord , , A_NEWREC
Form_Number = DOCNUMBER
'KEY value now on Subform -- aww 8/14/04
Forms![sfrmKeys_AW]![KEY] = NextKey
Forms![sfrmKeys_AW]![KEY].SetFocus

Exit_butAddNew_Click:
Exit Sub

DoCmd.SetWarnings (WarningsOn)

Err_butAddNew_Click:
MsgBox Error$
Resume Exit_butAddNew_Click

End Sub
===

Any idea on how to renumber Keys as described above?

Thanks!

amy
==

Nov 13 '05 #3

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

Similar topics

4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
1
by: Chris | last post by:
Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm going wrong? Thanks in advance and sorry again...
4
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function...
1
by: John Ryan | last post by:
What PHP code would I use to check if submitted sites to my directory actually exist?? I want to use something that can return the server code to me, ie HTTP 300 OK, or whatever. Can I do this with...
8
by: Beowulf | last post by:
Hi Guru's, I have a query regarding using PHP to maintain a user profiles list. I want to be able to have a form where users can fill in their profile info (Name, hobbies etc) and attach an...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.