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

renerating numbers BUT what about deleted

I was generating some numbers for a new database. Its based on some
entries the people do and it worked fine except for deleted records.

Private Sub generate()
Dim rst As Recordset
Dim maxof As Integer
Set rst = Me.RecordsetClone
If Not IsNull(Me.Level) And Not IsNull(Me.Control) Then
maxof = 0
If rst.RecordCount 0 Then
rst.MoveFirst
Do Until rst.EOF
If maxof < rst!GenNUMBER And rst!Level = Me.Level Then
maxof = rst!GenNUMBER
End If
rst.MoveNext
Loop
Me.GenNUMBER = maxof + 1
End If
If maxof = 0 Then Me.GenNUMBER = 1
Me.StudyID = "1" & [Level] & [Control] & Format(Me.GenNUMBER, "000")
rst.Close

End If
End Sub

this will go in find the MAX gennumber and just add 1.

but it you have 4 5 7 it will NOT go in and put in the 6 .

I said look you don't want that what if that number some how has to be
added BACK IN later, you assigned that number to a record then deleted
the record..

but they insist to fill in the list,, ok

I thought about in the loop adding something like

if isnull(rst!gennumber) then temp = maxof +1

and then using temp as the generate number but I am worried about one
thing...HOW can I test this to make sure in all instances?

does this sound like a good way to find missing numbers and generating
fillers into the missing ones (IF they exist)

yes the big problem in my mind is there are 3 different levels

1011 1012 1013
2011 2012 2013
3011 3012 3013

so I can't expect to end the loop on any certain value..


Jun 25 '07 #1
3 1312

"sparks" <js******@swbell.netwrote in message
news:bn********************************@4ax.com...
I was generating some numbers for a new database. Its based on some
entries the people do and it worked fine except for deleted records.

Private Sub generate()
Dim rst As Recordset
Dim maxof As Integer
Set rst = Me.RecordsetClone
If Not IsNull(Me.Level) And Not IsNull(Me.Control) Then
maxof = 0
If rst.RecordCount 0 Then
rst.MoveFirst
Do Until rst.EOF
If maxof < rst!GenNUMBER And rst!Level = Me.Level Then
maxof = rst!GenNUMBER
End If
rst.MoveNext
Loop
Me.GenNUMBER = maxof + 1
End If
If maxof = 0 Then Me.GenNUMBER = 1
Me.StudyID = "1" & [Level] & [Control] & Format(Me.GenNUMBER, "000")
rst.Close

End If
End Sub

this will go in find the MAX gennumber and just add 1.

but it you have 4 5 7 it will NOT go in and put in the 6 .

I said look you don't want that what if that number some how has to be
added BACK IN later, you assigned that number to a record then deleted
the record..

but they insist to fill in the list,, ok

I thought about in the loop adding something like

if isnull(rst!gennumber) then temp = maxof +1

and then using temp as the generate number but I am worried about one
thing...HOW can I test this to make sure in all instances?

does this sound like a good way to find missing numbers and generating
fillers into the missing ones (IF they exist)

yes the big problem in my mind is there are 3 different levels

1011 1012 1013
2011 2012 2013
3011 3012 3013

so I can't expect to end the loop on any certain value..

Maybe off the wall, but what if you have a 2nd table listing all the
assigned numbers. You could then use a unmatched query to find any
previously used numbers.
Jun 25 '07 #2
well I got the idea of making a small to the point list and sorting it
since the sort I hope will make this easier.
If you read thru a table like I did and have deletes and adds you will
have something like 001 004 002 003

so I got the idea of doing this
Dim strSQL As String
' Dim rst As Recordset
strSQL = "Select * From tblEnrollment Where rst!Level = Me.Level " &
"Order By rst!GenNUMBER"

Debug.Print strSQL
' 'open the results read-only
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
If rst.RecordCount 0 Then
rst.MoveFirst
Do While Not rst.EOF
Debug.Print rst!GenNUMBER
rst.MoveNext
Loop
End If

but I get 2 few parameters on the set rst line.... requires 3 ???
it must be something in my strsql statement but not sure
On Mon, 25 Jun 2007 09:03:58 -0500, "paii, Ron" <pa**@pack.comwrote:
>
"sparks" <js******@swbell.netwrote in message
news:bn********************************@4ax.com.. .
>I was generating some numbers for a new database. Its based on some
entries the people do and it worked fine except for deleted records.

Private Sub generate()
Dim rst As Recordset
Dim maxof As Integer
Set rst = Me.RecordsetClone
If Not IsNull(Me.Level) And Not IsNull(Me.Control) Then
maxof = 0
If rst.RecordCount 0 Then
rst.MoveFirst
Do Until rst.EOF
If maxof < rst!GenNUMBER And rst!Level = Me.Level Then
maxof = rst!GenNUMBER
End If
rst.MoveNext
Loop
Me.GenNUMBER = maxof + 1
End If
If maxof = 0 Then Me.GenNUMBER = 1
Me.StudyID = "1" & [Level] & [Control] & Format(Me.GenNUMBER, "000")
rst.Close

End If
End Sub

this will go in find the MAX gennumber and just add 1.

but it you have 4 5 7 it will NOT go in and put in the 6 .

I said look you don't want that what if that number some how has to be
added BACK IN later, you assigned that number to a record then deleted
the record..

but they insist to fill in the list,, ok

I thought about in the loop adding something like

if isnull(rst!gennumber) then temp = maxof +1

and then using temp as the generate number but I am worried about one
thing...HOW can I test this to make sure in all instances?

does this sound like a good way to find missing numbers and generating
fillers into the missing ones (IF they exist)

yes the big problem in my mind is there are 3 different levels

1011 1012 1013
2011 2012 2013
3011 3012 3013

so I can't expect to end the loop on any certain value..

Maybe off the wall, but what if you have a 2nd table listing all the
assigned numbers. You could then use a unmatched query to find any
previously used numbers.
Jun 25 '07 #3
On Jun 25, 8:10 am, sparks <jstal...@swbell.netwrote:
I was generating some numbers for a new database. Its based on some
entries the people do and it worked fine except for deleted records.

Private Sub generate()
Dim rst As Recordset
Dim maxof As Integer
Set rst = Me.RecordsetClone
If Not IsNull(Me.Level) And Not IsNull(Me.Control) Then
maxof = 0
If rst.RecordCount 0 Then
rst.MoveFirst
Do Until rst.EOF
If maxof < rst!GenNUMBER And rst!Level = Me.Level Then
maxof = rst!GenNUMBER
End If
rst.MoveNext
Loop
Me.GenNUMBER = maxof + 1
End If
If maxof = 0 Then Me.GenNUMBER = 1
Me.StudyID = "1" & [Level] & [Control] & Format(Me.GenNUMBER, "000")
rst.Close

End If
End Sub

this will go in find the MAX gennumber and just add 1.

but it you have 4 5 7 it will NOT go in and put in the 6 .

I said look you don't want that what if that number some how has to be
added BACK IN later, you assigned that number to a record then deleted
the record..

but they insist to fill in the list,, ok

I thought about in the loop adding something like

if isnull(rst!gennumber) then temp = maxof +1

and then using temp as the generate number but I am worried about one
thing...HOW can I test this to make sure in all instances?

does this sound like a good way to find missing numbers and generating
fillers into the missing ones (IF they exist)

yes the big problem in my mind is there are 3 different levels

1011 1012 1013
2011 2012 2013
3011 3012 3013

so I can't expect to end the loop on any certain value..
Whats the purpose for these numebrs? What are they to be used for/as?

Jun 25 '07 #4

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

Similar topics

5
by: Merlin | last post by:
Hello all! I'll make it short and sweet... I have a database, it looks something like this: id data --- ------------------------- 0 Some Data 1...
3
by: doug | last post by:
I am working on a C++ program in .NET. The compiler generates error messages that are associated with the wrong line numbers (which is extremely frustrating). Also, the debugger arrow is...
16
by: a | last post by:
We are writing an app that assigns people to teams based on their curent score. Teams are 8 people, there are 2 teams. (i would like it to be flexible, but this is a start). I need an algorithm...
24
by: Frank Swarbrick | last post by:
We have a batch process that inserts large numbers (100,000 - 1,000,000) of records into a database each day. (DL/I database.) We're considering converting it to a DB2 table. Currently we have...
9
by: Tom_F | last post by:
To comp.databases.ms-access -- I just discovered, to my more than mild dismay, that some tables in my Microsoft Access 2003 database have duplicate numbers in the "AutoNumber" field. (Field...
9
by: MLH | last post by:
A mailing list table in its virgin state contained sequential, consecutive integers in an autonumber field (A97). I've deleted records throughout the table. Now I would like to identify each...
2
by: mindrage00 | last post by:
Hi! I am creating an image gallary where the images are numbered 1, 2, 3 etc. Users will be uploading the images so if i need to delete an image, I need the code to be able to check if that number...
12
by: magmike | last post by:
Accidentally deleted a record. Anyway to get it back? If not, I know the ID number - which is an autonumber field. Because of the related data from other tables, would I be able to create a new...
1
by: Rob | last post by:
Is it possible to prevent a row from being deleted in a table. I want to arrange a new table with an autonumbered primary key that will form part of a set of sequential serial numbers. I want to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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.