473,748 Members | 8,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

generating seq numbers ok till they decided to change it

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 Integer
Dim gennum As Integer
Dim finalnum As Integer
Set db = CurrentDb
Set rs = db.OpenRecordse t("SELECT Max(qryParticip antids.gennumbe r) AS
MaxofGenNUMBER FROM qryParticipanti ds;")
If Not IsNull(Me.Level ) And Not IsNull(Me.Contr ol) Then
If rs.RecordCount 0 Then
rs.MoveFirst
Me.GenNUMBER = rs!maxofGenNumb er + 1
'gennum = rs!maxofGenNumb er + 1
Debug.Print " level = " & Level
Debug.Print " control = " & Control
Debug.Print gennum
'finalnum = [Level] & [Control] & Format(gennum, "000")
'Me.StudyID = [Level] & [Control] & Format(Me.GenNU MBER, "000")
Me.StudyID = "1" & [Level] & [Control] & Format(Me.GenNU MBER, "000")
Debug.Print "finalnum = " & finalnum; ""
' Me.StudyID = "C" & Format(Me.GenNU MBER, "0000")
Debug.Print "StudyID = " & Me.StudyID
Debug.Print "genNumber = " & Me.GenNUMBER
rs.Close
End If
Set db = Nothing
End If
End Sub

=============== =============== =============== =============== =============== ==
qryParticipanti ds is a union query so I could get a number starting at
000
This is retarded the more I look at it

SELECT gennumber from tblEnrollment UNION select 0 as gennumber
FROM tlkprace;
=============== =============== =============== =============== =============== ==
Now they want to make it so that the numbers can be 1001 2001 3001
based on the level which is the first number then 001-0150 so 2001
would be level 2 001

so I thought about this for the selection

SELECT Max(tblEnrollme nt.GenNUMBER) AS MaxOfGenNUMBER FROM
tblEnrollment GROUP BY tblEnrollment.L evel HAVING
(((tblEnrollmen t.Level)=[me].[level]));

[me].[level] is from the forms.

but if I do Set rs = ("SELECT Max(tblEnrollme nt.GenNUMBER) AS
MaxOfGenNUMBER FROM tblEnrollment GROUP BY tblEnrollment.L evel HAVING
(((tblEnrollmen t.Level)=[me].[level]));")

i get too few parameters was expecting 1

I can't come up with a way to generate 001-150 by taking the max
number of the number with the level.

any help or pointers would be greatly appreciated.

thansk big time

Jun 14 '07 #1
1 1577
well I thru all that stuff away and tried something simple

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
End If

Me.GenNUMBER = maxof + 1
Me.StudyID = "1" & [Level] & [Control] & Format(Me.GenNU MBER, "000")
this seems to work and I get good number generating.

I got 111001 and 111002 121001 121002 so I feel confident it will
work for a while

well I am sure someone will find a way to mess it up but so far so
good and its simple

On Thu, 14 Jun 2007 14:44:02 GMT, sparks <js******@swbel l.netwrote:
>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 Integer
Dim gennum As Integer
Dim finalnum As Integer
Set db = CurrentDb
Set rs = db.OpenRecordse t("SELECT Max(qryParticip antids.gennumbe r) AS
MaxofGenNUMB ER FROM qryParticipanti ds;")
If Not IsNull(Me.Level ) And Not IsNull(Me.Contr ol) Then
If rs.RecordCount 0 Then
rs.MoveFirst
Me.GenNUMBER = rs!maxofGenNumb er + 1
'gennum = rs!maxofGenNumb er + 1
Debug.Print " level = " & Level
Debug.Print " control = " & Control
Debug.Print gennum
'finalnum = [Level] & [Control] & Format(gennum, "000")
'Me.StudyID = [Level] & [Control] & Format(Me.GenNU MBER, "000")
Me.StudyID = "1" & [Level] & [Control] & Format(Me.GenNU MBER, "000")
Debug.Print "finalnum = " & finalnum; ""
' Me.StudyID = "C" & Format(Me.GenNU MBER, "0000")
Debug.Print "StudyID = " & Me.StudyID
Debug.Print "genNumber = " & Me.GenNUMBER
rs.Close
End If
Set db = Nothing
End If
End Sub

============== =============== =============== =============== =============== ===
qryParticipant ids is a union query so I could get a number starting at
000
This is retarded the more I look at it

SELECT gennumber from tblEnrollment UNION select 0 as gennumber
FROM tlkprace;
============== =============== =============== =============== =============== ===
Now they want to make it so that the numbers can be 1001 2001 3001
based on the level which is the first number then 001-0150 so 2001
would be level 2 001

so I thought about this for the selection

SELECT Max(tblEnrollme nt.GenNUMBER) AS MaxOfGenNUMBER FROM
tblEnrollmen t GROUP BY tblEnrollment.L evel HAVING
(((tblEnrollme nt.Level)=[me].[level]));

[me].[level] is from the forms.

but if I do Set rs = ("SELECT Max(tblEnrollme nt.GenNUMBER) AS
MaxOfGenNUMB ER FROM tblEnrollment GROUP BY tblEnrollment.L evel HAVING
(((tblEnrollme nt.Level)=[me].[level]));")

i get too few parameters was expecting 1

I can't come up with a way to generate 001-150 by taking the max
number of the number with the level.

any help or pointers would be greatly appreciated.

thansk big time

Jun 14 '07 #2

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

Similar topics

6
5542
by: Poul Møller Hansen | last post by:
I have made a stored procedure, containing this part for generating a unique reference number. SET i = 0; REPEAT SET i = i + 1; SELECT RAND() INTO reference FROM SYSIBM.SYSDUMMY1; SET p_reference = ref_prefix || SUBSTR(CAST(reference AS CHAR(12)),3);
1
30925
by: Intaek LIM | last post by:
generally, we use srand(time(0)) to generate random numbers. i know why we use time(0), but i can not explain how it operates. first, see example source below. --------------------------------------------- #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv)
13
1560
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 understand since it is not generating the required results.- Thank you in anticipation - Vasudev. #include <stdio.h> main () { char student, *x;
6
5910
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. Since the time b/w execution is very similar, many simulation runs resulted in exact same results. Is there a better way of seeding the random number generator in c/c++
9
1882
by: jasonrholland | last post by:
i have to build a table within access that receives it's information from an ASP web page and generates the primary key, with numbers and letters, from the data submitted. a numer would be like this 06TTAG1202, but a little more complicated . the 06 would be from the current year at time of submission, the TTAG would remain constant, the 12 would come from the information in the county feild (counties x,y, and z would receive the...
8
25473
by: kiranchahar | last post by:
Hey all, How do I generate random numbers with Uniform distribution Uniform(a,b) using C-programming? I want to generate uniform random numbers which have mean following Uniform(p,q) and also variance as Uniform(s,t)? any suggestion would be really appreciated. Thanks, Kay
12
2975
by: 9966 | last post by:
Greetings, This is my second post till now. Thanks for all the advice given to me for the first post. Now I'm having problem with generating random numbers. I know if we want to generate a random number, we can use: int tempNUM = rand(); But, once I execute the program, the generated number is always similar, and I found this from the internet. It says need to add this line to make the numbers generated differently:
0
1882
by: Aswanth | last post by:
I'm Working with Asp.Net with C#.. & I'm Generating Reports in SSRS-2005.. Till Now I'm Generating Reports in SSRS-2005 with Stored Procedure.. in Which I'm Generating Reports for One Particular User Details(ie I wrote Stored Procedure for Getting One Users Details).. Now I Want to Generate the Reports for Different Users DYNAMICALLY (Here, I wrote another Stored Procedure which contains UsersID's as Input...
26
7913
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()); int r2 = rand(); bool f = r1 == r2;
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9537
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9243
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.