473,387 Members | 1,492 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,387 software developers and data experts.

Generating a number...simple but

ok I was generating a combo of things into a unique identifier.

Private Sub generatenumber()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim StudentNumber As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT Max(qryParticipantids.gennumber) AS
MaxofGenNUMBER FROM qryParticipantids;")
If rs.RecordCount > 0 Then
rs.MoveFirst
Me.GenNUMBER = rs!maxofGenNumber + 1
Me.StudyID = "S" & Format(Me.GenNUMBER, "0000")
End If
rs.Close
Set db = Nothing
End Sub

so they get a studyID sequence
S0001
S0002
S0003

this worked fine but now they want to get a studyID
S0501
S0502
S0503

how can I get this with an empty recordset.
since the IF is not really needed since you call this on new record
the count will always be 1.

thanks for any ideas...this is weird
why do they always want something that to me makes no since.

Jerry
Mar 24 '06 #1
2 1233
On Fri, 24 Mar 2006 14:13:30 GMT, sparks <js******@swbell.net> wrote:

How about:
Me.GenNUMBER = rs!maxofGenNumber + 1
If Me.GenNumber < 501 then Me.GenNumber = 501
Me.StudyID = "S" & Format(Me.GenNUMBER, "0000")

-Tom.

ok I was generating a combo of things into a unique identifier.

Private Sub generatenumber()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim StudentNumber As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT Max(qryParticipantids.gennumber) AS
MaxofGenNUMBER FROM qryParticipantids;")
If rs.RecordCount > 0 Then
rs.MoveFirst
Me.GenNUMBER = rs!maxofGenNumber + 1
Me.StudyID = "S" & Format(Me.GenNUMBER, "0000")
End If
rs.Close
Set db = Nothing
End Sub

so they get a studyID sequence
S0001
S0002
S0003

this worked fine but now they want to get a studyID
S0501
S0502
S0503

how can I get this with an empty recordset.
since the IF is not really needed since you call this on new record
the count will always be 1.

thanks for any ideas...this is weird
why do they always want something that to me makes no since.

Jerry


Mar 24 '06 #2

No thats too easy.
What else you got.
LOL

thanks for the help I could not see that to save my life.
I was thinking that if would always be 501.

thanks again

Jerry


On Fri, 24 Mar 2006 07:21:16 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Fri, 24 Mar 2006 14:13:30 GMT, sparks <js******@swbell.net> wrote:

How about:
Me.GenNUMBER = rs!maxofGenNumber + 1
If Me.GenNumber < 501 then Me.GenNumber = 501
Me.StudyID = "S" & Format(Me.GenNUMBER, "0000")

-Tom.

ok I was generating a combo of things into a unique identifier.

Private Sub generatenumber()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim StudentNumber As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT Max(qryParticipantids.gennumber) AS
MaxofGenNUMBER FROM qryParticipantids;")
If rs.RecordCount > 0 Then
rs.MoveFirst
Me.GenNUMBER = rs!maxofGenNumber + 1
Me.StudyID = "S" & Format(Me.GenNUMBER, "0000")
End If
rs.Close
Set db = Nothing
End Sub

so they get a studyID sequence
S0001
S0002
S0003

this worked fine but now they want to get a studyID
S0501
S0502
S0503

how can I get this with an empty recordset.
since the IF is not really needed since you call this on new record
the count will always be 1.

thanks for any ideas...this is weird
why do they always want something that to me makes no since.

Jerry


Mar 24 '06 #3

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

Similar topics

13
by: vasudevmukherjee | last post by:
Hi! Can somebody help tell me why the following code gives a garbage value while producing first student's name, whereas it gives the names correctly for other three students - I really fail to...
7
by: Gerard Flanagan | last post by:
All would anyone happen to have code to generate Cutter Numbers: eg. http://www1.kfupm.edu.sa/library/cod-web/Cutter-numbers.htm or is anyone looking for something to do?-) (I'm under...
18
by: baltimoredude1 | last post by:
Hi I was writing a simple code to generate the first 100 prime numbers. Everything looks fine to me except the output of the program. What's wrong with it? I am attaching the program as well as...
6
by: Intiha | last post by:
Hello all, I am trying to generate random seeds for my simulations. currently i was using srand(time(NULL); for this purpose. But for confidence in my results i ran it using a script in a loop....
2
by: Simon Wittber | last post by:
I'm building a web application using sqlalchemy in my db layer. Some of the tables require single integer primary keys which might be exposed in some parts of the web interface. If users can...
0
SammyB
by: SammyB | last post by:
These are some "random" thoughts about generating random numbers in Visual Basic. Wikipedia will give a better introduction than I, see http://en.wikipedia.org/wiki/Random_number_generator. ...
1
by: sparks | last post by:
we are generating numbers for the data collection people. this worked fine for a while.. Private Sub generatenumber() Dim db As DAO.Database Dim rs As DAO.Recordset Dim StudentNumber As...
4
by: RSH | last post by:
Okay my math skills aren't waht they used to be... With that being said what Im trying to do is create a matrix that given x number of columns, and y number of possible values i want to generate...
26
by: bilgekhan | last post by:
What is the correct method for generating 2 independent random numbers? They will be compared whether they are equal. What about this method: srand(time(0)); int r1 = rand(); srand(rand());...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.