Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




(RESOLVED)(VB6)Auto Increment Number In Access


Hon'ble gurus,
I use Access2002 and VB6. My project is a school project. I have 2 comboboxes and one textbox. In my Access database I've already entered data. In combo1 I show the classes like LKG,UKG,STD I,STD II,STD III etc. In combo2, I show the names of students found in that particular class which is selected in Combo1.Let's assume that the maximum strength in each class is 100. Now I want to allot Roll no to students of different classes in a particular way. For example: Students of LKG should have Roll no starting from 101. Students of UKG should have Roll no from 201. Students of STD I should have Roll no from 301 like this. In the textbox if I write the first roll no of a class, can I allot roll no to all students of that class in auto increment way? Hope, you got me.Right? I mean, if I choose UKG and in the textbox I write 501 then roll no should be added in database against all students of that class like 501,502,503,504 and each name. The roll no should be incremented till the no of students are found in the class. Is it possible throught VB6 coding? Thanks.

pkb_pkb

Edited by - pkb_pkb on 6/28/2007 3:58:50 AM




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Generate Auto-Number Increment In A MS Access Report
I would like to insert a automatic number field in a report that is not bound to any table. I.E. if I wanted to insert the date or time, I would simply type" =Date() ". However I would like to have every report that I generate include a auto number/random number. Any Suggstions?

PS This is for a MS Access 2000 report page.

Auto Increment Of A Number According To Year....
Hi Friends,

I have a problem here,I want to increase the number like this ....
2002/1 ; 2002/2 ; 2002/3 ; 2002/4 .......
2003/1 ; 2003/2 ; 2003/3 ; 2003/4 .......
like wise.....
If I select the year from combobox then according to the year the number should increse and that should be concatinated to the year and the whole should be pasted in text box.....Using Ms-Access as a database and VB as frontend......
Thanks

Auto Increment Number With Alpha Numeric
hi!,
  could you tell me how to create codes in VB about Auto increment with alpha numeric?

example:
    001A01B

thanks.

Zeroing An Auto Increment Field In ACCESS
HI

i have 1 field (usually the key field) which is defined as auto increment.
i made some tests and now want to delete all records.
the problem is that rows are deleted but when i will find a new 1
the auto increment field wont start from 0 but from the last number
it was the last time.

so how would i zero it ?

Set A Starting Value For An Auto-increment Field In MS Access
The topic says it all !


I want to have a key field (auto-increment) in one of my table, but I need it to start at 542 instead of 1 which is default starting value.


Is it possible to do?

Thanks.



Edited by - dbelley_office on 2/8/2005 8:14:26 AM

Creating Ms Access Auto-increment Primary Key Using SQL Query
Hello all,

I wonder if anyone can help me with this..

I have MS Access database with a table(say "TABLE1) with primary keys already. Now, we want to add an auto-increment (AutoNumber) field (say FLD1) as the only primary key for that table.

I think I have to
- firstly add FLD1 to the TABLE1 as normal field first,
- fill FLD1 with value for existing records.
- add primary key (FLD1) to TABLE1
- drop old primary keys

Am I correct with the procedure?

Also, the other question is how can I add primary key FLD1 as auto-increment number field with SQL query in my VB6.

Please advise!!!

My Ma Database Uses Auto Number (Resolved-Thanks Deke)
Hi, I am using vb and a ma database with an auto number as a primary key. When I add a new record in, its fine the number increases. However, if I delete a record, that number is gone. I am wondering if it is possible to somehow use this lost number again. I would like to use this number as when I pull out the records with SQL, I would like them to be ordered 1,2,3,4... etc and not all over the place like 1, 23, 24, 45... etc
Thanks

thanks
leadfinger
http://www3.nbnet.nb.ca/gspil

Edited by - leadfinger on 3/6/2003 11:13:10 AM

Auto Increment
I have a form that I want to have a number in a textbox for example increment every time the user clicks a command button. I know how to do this, but when the application closes the number gets reset. Textbox.text=103 is at the start. When the user clicks it goes to 104 etc. If the application is closed, I want the number to remain as 104 and whne it is opened again and the user clicks, the number will change to 105 etc.
Thanks

Auto Increment
hi all experts,
I have 4 different tables in MS-ACCESS.
i'm doing project for an engineering company. So they have different jaws for CNC machines. like OD DIAMETER, ID DIAMETER, MULTIPLE OD DIAMETER and MULTIPLE ID DIAMETER
i want to keep track of each issue of jaws to the worker......
so my question is that can i get one receipt number which is AUTO INCREMENT......and that will be unique for each issue of jaw.......is it possible to track 4 tables for AUTO INCREMENT of the receipt number.....

i think i'm clear in describing my question.........

need help
sachin

Auto-Increment
I need to auto-increment a number field but I don't want to use the auto-increment in the .mdb database. Anyone know how to do this? I'm using vb6 with the adodc data control.

Thanks

Auto Increment
Hello.

In database, I would like change one field property. The num auto of my field property is true and i would it become false.


How can i do ?

Thank's
CBC

How To Get Next Auto Number In Access 2K?
In Oracle, we can find next synonym number as synonym_name.nextval

Is the any similar way to get next Auto Number value for a field in Access?

Thanks.

Help With Auto Number In Access
hi, i have a field in my access table called contactID, it is an auto number,

Is there a way in VB i can display in a label the AutoNumber +1, (so the next number that will be used).

Cheers

Auto Number In Access
Hello,

Ok, basically i'm looking to see if anyone knows if Access can get data from a field from the previous record when designing the algorithm for the auto number feature. My field name i need to get from the previous record is E_endAmount, i need this in order to update the E_EndAmount field for the next record. E_EndAmount = E_endamount(previous record) + E_amount

OR

I need a way to find the previous record E_EndAmount through VB6

Thanks,

Greg Watson

           All your base are belong to me
               ( º)> ~ <(º.º)> ~ <(º )

Auto Increment Alphabet
Hi All,
I am new to VB and im trying to solve a tricky issue.
I am trying to loop through the alphabet a-z and have the vaule appear in a text box on my access form.I also wnat the dat to appear(20060420) before the letter? i dont know how to do this? So everytime a user submits a new record the date will appear with a new letter will appear? the below code works in the befor e_Insert property, but it only increments one letter? Can you enhance this or give me pointers?


Thanks


Code:
Private Sub Form_BeforeInsert(Cancel As Integer)

thisletter = "A"
thisletter2 = "B"


If Me.NewRecord = True Then
nextletter = Chr(Asc(thisletter) + 1)


End Sub

How Does Auto Increment Work?
What does VB consider to be a major, minor and revision when auto increment is turned on, and is there any way to change this?

Auto-increment Version
Is there any way to make VB always check the auto-increment version box in the project properties when creating a new project? Maybe a registry key or something?

Inserting The Auto Increment Value From VB
Hi !!
i wrote a good working vb program that stores automatically data from IRC to mysql DB. The only problem i have now is i want to create a php webpage and i realized it would be a good thing if i had a column that contained the row #.
Therefore, i added a rowid column in the db but i have no idea on how to INSERT a value automatically in a field so that it respect the auto increment value.

conn.Execute "INSERT INTO releases VALUES (" & _
"'" & txtDate.Text & "', " & _
"'" & txtTime.Text & "', " & _
"'" & txtChan.Text & "', " & _
"'" & txtSentence.Text & "', " & _
"'" & txtWho.Text & "', " & _
"'" & LAST_INSERT_ID & "')"
End Function

The "'" & LAST_INSERT_ID & "')" is the one that doesnt work good. Of course VB returns "unknown variable" but i have no clue of what to replace it for.
Do i have to write a few lines to read the last rowid # in the column and then calculate the new rowid for the insert ? Or, is there any way to skip a column when inserting a row, so it would auto add it's own rowid value ?
I see many possibilies
but i dunno wich one will work

Thanks !

How To Auto Increment Primary Key
wonder how i can autom increment primary key of table when ever i insert a new record using asp.net web form? i want to insert some data to sql server db using web forms.Thank u and looking forward to your replyes.Thanks

Auto Increment Field
I am using the recordset addnew method to add data to an ms sql server 2000
database table, which has an auto increment field.
However i am unable to get back the auto increment field in the table.

Thank for your help.

How To Get Auto Increment Field From ADO
Hi,
   I am created a table with auto incremented field as a primary key in Ms Access table. I am using ASP to insert a record into the table. I wonder how can I get back the auto incremented field from ADO. My code is showed as below:

 Set cnn = Server.CreateObject("ADODB.Connection")
 cnn.Open CONSTR
                          strsql = "Insert into table1 (firstname, lastname) values ('xxxxx', 'yyyyy')"

cnn.Execute strtemp, , adCmdText + adExecuteNoRecordscnn.Close
set cnn = nothing        

Auto Increment Field
In SQL you can create a Table in MS ACCESS by


Code:
Create Table MyTable (RecNo Long, Data1 Text(50), Data2 Text(50))


Using MS Access manually, I can create the RecNo as an Auto Incrementing Counter Field, but by using an SQL Statement, how do I do it ?

My problem is that I can't find a data type which is an Auto Incrementing field

Thanks

(I would prefer to use an SQL Statement)

ALSO

Will that work in SQL Server 2005 ?

Access To ORACLE What About Auto Number?
I went out and Bought the Intelligent Converters tool...
http://www.convert-in.com/acc2ora.htm

It seems to have converted all the data over to the Oracle server.

But, what happens to the Auto Number fields now that the DB is in Oracle?

I used to insert into an Access table like so...

sqlINSERT = "INSERT INTO tblPhaseData (" & _
"PR_Index, " & _
"intPhaseSeqNum, " & _
"strPhaseName, " & _
"strPhaseDescription) "
sqlVALUES = "VALUES (" & _
"" & PR_Index & "," & _
"" & myPhaseNum & "," & _
"'" & Replace(Project.StandardPhases(X, 1), "'", "''") & "'," & _
"" & Project.StandardPhases(X, 2) & ")"

SQL = sqlINSERT & sqlVALUES
Call dbx(SQL, True)
SQL = "SELECT @@identity"
Call dbx(SQL, True)
PH_Index = CLng(rs(0).Value) ' get the Auto Number Field here



Can I use this same method going forward?
(with a new connection string of course)

Or does Oracle require me to handle things differently?

Also, I am not able to query the data using SELECT statements.
Error returned is "Table or View does not exist"


Can anyone help me better undertand what's wrong?

Thanks a bunch.

Auto Number Field In MS Access
Can I reset the value of an auto-number field in an MS Access Database through VB.
My problem is that I create new fields and also delete fields therefore the autonumber field is getting very large. Any help welcome

Addnew() Problem With Auto Increment Id
Hi,

I am writting a program using VB.Net to connect to a MSSQL Server 2000 database by ADO.Net technology. My database has four tables, namely "Patients", "Lesions", "Measurements" and "Files". They are all in a series of "one to many" relations.For example, one patient can have multiple lesions and one lesion can have multiple measurements and one measurement
can have multiple files. I use auto increment integer number as the "id"s of table "Lesions", Measurements", "files", and set their seeds and as "identical".

I have a problem to add a new record for the tables with auto increment numbers as their "id"s. Whenever I called the addNew() meathod to add a new record to, for exampel, the "Lesions" table, the number of "id" shown is always a number larger than it should be. In my case, it's always two more than it should be in the "Lesions" table, for example, I already have 3 records with "id" 0, 1, 2, in the table, the next (new) one I add should be with "id" 3, but it actually comes up with "id" 5. Then this conflicts with the table so if I update the data adaptor, there are two new records shown up, one with "id" 3, the other with "id" 5. Of course the one with "id" 5 is invalid, so any work with it will end up with an error. I have to close the form and restart it, then the devil record with "id" 5 disappear, and everything now is OK.

Can somebody please give me some hint to solve this problem? It's a real time killer for me.

And I also noticed there is a post with same problem marked with solved, but there was simply no reply to the thread.

Thank you,

adHeadache

5 Digit Auto Increment Problem
hello..
I have this little problem which i cannot get it

I want to auto increment a 5 digit number like this:
(it shoud always stay as 5 digits)

00001
00002
.
.
00010
00011
.
.
00100
00101
.
.
.01000

hope someone can help me out!!!

Auto Increment Field In VBA Problem.
Hi guys.....
i have created one formuser that included ReportNum field.
when user clik cmdjobrequest in main menu,it should go to formuser and the ReportNum automatically incremented.

i apply this code in the cmdjobrequest:


Code:


Private Sub cmdjobrequest_Click()
Me![ReportNum] = NewReportNum()
Me![requestor].SetFocus
Me![cmdjobrequest].Enabled = False
End Sub

Public Sub EnableIfNull()

Dim intControlCounter As Integer
Dim binAllNull As Boolean
Dim MyForm As Form
Dim MyControl As Control

Set MyForm = Me
binAllNull = True

'Look at all text boxes to check if they are null
For intControlCounter = 0 To MyForm.Count - 1
Set MyControl = MyForm(intControlCounter)

If TypeOf MyControl Is TextBox Then
If Len(MyControl) > 0 Then 'The Value property is assumed (MyControl is same as MyControl.Value)
binAllNull = False
Exit For
End If
End If

Next intControlCounter
If binAllNull = True Then
cmdjobrequest.Enabled = True
Else
ccmdjobrequest.Enabled = False
End If

End Sub

Private Sub Form_Current()
EnableIfNull
End Sub


And this is put inside the ReportNumber modules:

Option Compare Database

Public Function NewReportNum() As Double
On Error GoTo NextReportNum_Err

Dim cmdjobrequest As Double

ReportNum = DMax("[ReportNum]", "JobRequest") + 1


NewReportNum = cmdjobrequest
Exit_NewReportNum:
Exit Function

NextReportNum_Err:
MsgBox "Error " & err & ": " & Error$

Resume Exit_NewReportNum

End Function



please anyone help me....i was stuck with this......

Auto Increment An Integer With Date
hello
i have a problem,if u have a solution pls sent to me

i want to auto increment an integer, thatis 1,2,3....so on
but when the date (dd/mm/yyyy) the year changes to new for egs 2004 to 2005
the record will set to 1

if i get the first record as 1/2004 the last record is 17900/2004
in the year 2004 when i change the day of dec 31 to jan 1st i would want the
record as 1/2005 if u have a solution pls ent to me,i am using dtpicker for
accepting the date
regards





Yahoo! India Matrimony: Find your life partneronline.

Auto Increment Problem Using MySQL
Hi, I use an INSERT INTO stament in adding a record on MySQL database. But when I check the content of my table, the primary key ID which is set to auto increment does not increment its value. The field ID is always set to zero, but in my SQL statement, I did not include that field. I have four fields on my table (id, lastname, firstname, middlename). Below is my SQL statement using Visual Basic, this is coded on air.

Code:
'strConnection was initialized on the module
Dim adConnection as ADODB.Connection
Set adConnection = New ADODB.Connection
adConnection.ConnectionString = strConnection
adConnection.Open
adConnection.Execute "INSERT INTO persons(lastname, firstname, middlename) VALUES ('dela Cruz','John','Co')"
adConnection.Close




Edited by - gee on 12/16/2007 5:58:28 PM

Auto Increment + Password Feature
hello, I'm writing a program (no database) that will store information into a csv file. I need to have a 'transaction number' whereby it will increment itself on every transaction. how do I go about doing it? I hope I wouldn't need to read it from a file or something. The app may be run a few times a day so I hope the app will 'remember' the number.

Also, I would like to implement 'admin features' in my program. I intend to have the app ask for the password whenever someone tries to access the admin functions. how shld I implement this feature (as in how do I store the password?) and is it possible to allow the admin to change password as and when s/he wants to,without storing the password in a file/registry?

I've tried seaching thru the threads but to no avail (mayb i'm using the wrong keywords?). I hope someone can help me out. My thanx to everyone!

Sql INSERT And Access Auto Generate Number
Yet another query from me...

When a new contact is created, I INSERT a record into the ContactDetails table using sql. Access auto-generate the ContactID, but I need to know what the ContactID is so I can insert another record in the DBEntries table.

Below is the code I currently use. I've tried many ways withouth success, but maybe I just don't know sql good enough.

'Sql statement to insert ContactDetails record:
oRS.Open "INSERT INTO ContactDetails(Name1, Name2, Surname, JobTitle, Company, Address1, Address2, Address3, Town, PostCode, Workphone, Fax, Mobile, Email, Website, ContactInfo, CompanyInfo) VALUES ('" & Trim(gName1) & "', '" & Trim(gName2) & "', '" & Trim(gSurname) & "', '" & Trim(gJobTitle) & "', '" & Trim(gCompany) & "', '" & Trim(gAddress1) & "', '" & Trim(gAddress2) & "', '" & Trim(gAddress3) & "', '" & Trim(gTown) & "', '" & Trim(gPostCode) & "', '" & Trim(gWorkphone) & "', '" & Trim(gFax) & "', '" & Trim(gMobile) & "', '" & Trim(gEmail) & "', '" & Trim(gWebsite) & "', '" & Trim(gContactInfo) & "', '" & Trim(gCompanyInfo) & "')"

'Sql statement to insert DBEntries record, executed right after first statement
oRS.Open "INSERT INTO DBEntries (ContactID, BusTypeID, DBID, DBEnteredDateTime) " & _
"VALUES (SELECT LAST(ContactDetails.ContactID) AS LastContactID FROM ContactDetails ORDER BY ContactDetails.ContactID ASC, " & gBusTypeID & ", " & Get_DBID("CONTACT") & ", #" & Format(Now, "mm/dd/yyyy hh:mm:ss") & "#"

Build A Table With Auto-increment Field...
Greetings all!

I am trying to build a table like this:

fkField (primary key)
fkButton (primary key)
iNumber (primary key)

And the values I need to have are this:

fkField - fkButton - iNumber
1 ----------- 1 ---------- 1
1 ----------- 1 ---------- 2
1 ----------- 2 ---------- 1
2 ----------- 2 ---------- 1
2 ----------- 2 ---------- 2
2 ----------- 2 ---------- 3

I would like the column "iNumber" to be an automatic increment counter that return to 1 for every new pair of "fkField" - "fkButton".

I know that in my Database courses we talked about something like this (famous example of an invoice for each client...), but I allways wonder if ther was an option or a setting for SQL to do this with my column "iNumber" automagically, or I really need to do it programatically.


Thank you for your time and have a nice day!

Auto Increment Of Records Not Taking Place?
Hi everyone,

I am facing a very unique problem. I have written a code for auto incrementing of registration numbers. The auto increment takes place when the form loads or the record is added.

Now the problem is after 13810 records the code is refusing to auto increment. The records are getting added, but with the number 13810. Can u guys please suggest what is causing this out of the blue error?



Code:
Public Sub Autogenregest()
On Error Resume Next
Dim a As Long, b As String

If rs1.State = 1 Then rs1.Close
rs1.Open "clientprofile", con, adOpenDynamic, adLockOptimistic
If rs1.BOF = True And rs1.EOF = True Then
brs.Open "Backup", con, adOpenDynamic, adLockOptimistic
a = Val(brs(0).Value)
brs.Close

b = "C" & a
TxtRegNo.Text = b
Else

rs1.MoveLast
a = Val(Right(rs1(0).Value, Len(rs1(0).Value) - 1) + 1)

b = "C" & a

TxtRegNo.Text = b
End If
End Sub



Regards,
Kaushik

Auto-increment Text Form Fields In MS Word
I have a Word document with four forms on a page. Each of the four forms has a text form field which I want to have consecutive numbers in. So if I print 10 sheets the forms will be numbered 1 through 40.
Is it possible to attach a macro to each of these fields to increment each of them by one every time a new page is printed.
It would be nice to have a window opening to ask which number to start at

Thanks in advance

Geoff

Code For Auto Increment Field Values In Datagrid Recordset Entries
Hello Friends

I was creating Master Detail form in visual basic-Oracle8 & want to create auto increment value field for each row of recordset .
Say - Increment - Serial number values in Serial Number column field while making entries.

My Problem :
Could not able to write the code and identifying events for generating incrment values after insert of record in recordset

Note: Serial Number field in not primary/foreign key & can have duplicate values.

So help required to know how to write increment code with revelant events . So whenever new records are being inserted serial number datadrid field IN RECORDSET will generate auto increment values for next records.

Regds

Ashish Dadel

 

Generating String Type Auto Serial Number For Primary Key Of A Access Database Table
Down Load the file and check the code, Love to see your comment on it. Thank you.

Increment 5 Digits Number
Hello, I need help here. What I'm trying to do:

1) to has a function that will generate a unique 5 digits number that will increase everytime I call the function. I want to use it as slip number. It start from 00000 to 99999. If it more than 99999 then it will be reset to 00000.

2)this function will search in the table whether the number generated already existed or not, if yes it will increment the number if no then it will assign the number to the txtfields(1).

Below is my code but it doesn't work well.

code:
________________________________________________


Private Function tranNo()
Static code1 As Double
start:
txtFields(1).Text = Format(code1, "00000")
txtFields(1).Refresh
If code1 < 99999 Then

If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
Do Until Adodc1.Recordset.EOF
If Adodc1.Recordset("tranNo") = code1 Then
code1 = code1 + 1
GoTo start:
Else
Adodc1.Recordset.MoveNext
End If
Loop

End If

Else
code1 = 0

End If


End Function

___________________________________________________

In summary, this number like an autonumber. Can anyone help me to correct the code, or suggest another way to do it? Help me please!

Increment For A Number With The Alphabet...
Dear all,

Can anyone teach me how to increase the number with the alphabet as well?

For Example, "A00001", everytime, when i click the command button, it will automatically + 1, "A00001" -> "A00002-> "A00003 -> "A00004 -> ... until "A99999"

Many Thanks...

Regards,
Nicholas

Increment The Invoice Number
i am working a Simple invoice but i need it to auto increment the invoice number.
want when Comand Button that once clicked increases the number in Range 1 by one already save number.

please if some one have any simple project please send it to me.
i am really thankful to you .

How To Make Number Increment In A String?
For example the last member's ID from the database is "TP0022", then if got another guy make a new registration he/she will get the ID "TP0023".

How Do I Increment An Hex Number Inside A String?
I have this string:
"ecc9ddaa-6643-429b-9844-8dc429826254"
and I want to add a number to the last section, I splited this string:
Lsec(0)= "ecc9ddaa"
...
LSec(4) = "8dc429826254"

Now I want to add 15 to this number (Lsec(4)), and then change it back to a string so I can get something like this:

"ecc9ddaa-6643-429b-9844-8dc429826263"

Any ideas?? :S

btw ... I'm using VB 2005

I Need VB Code For Auto Increment Naming Captured Digi Pics And Default File Save Location
I'm writing an application in VB which automates snap shot captures as jpg's. I want to auto-save the images to a default folder on my hard drive in sequence from lets say, ex: pic1.jpg ; pic2.jpg ; pic3.jpg ; etc... on through approx 80 jpg images which would be pic80.jpg after each digi pic is snapped,,,,, The idea behind this is to have my digi camera snap/save automatically and incrementally naming the images throughout the routine. What source code would best fit my needs to accomplish such a feat? Like I said, I need to set a default path to a folder on my hard drive and have the images saved in numeric sequence. thx

Solved: Increment About Form Version Number
Happy holidays!!

Can someone explain how to increment the About form version number? It just stays at 1.1.0. Other than not incrementing the form looks just fine. The code in the About form includes...
Code:
Private Sub Form_Load()
    Me.Caption = "About " & App.Title
    lblVersion.Caption = "Version " & App.Major & "." & App.Minor & _
                           "." & App.Revision
    lblTitle.Caption = App.Title
    lblDescription.Caption = "This program was written by ...blah blah"
    lblDisclaimer.Caption = "Warning: ...This program is protected ....blah"
End Sub

..but there is also under - project properties - make, the version number Major, Minor, Revision.
I have them each set to 1. And, the Auto increment is checked. But, I'm not sure about under Application the Title and Icon part. The drop down for the Icon just lists all the different forms I have in this project. I don't think of a form as an icon what am I missing here?

Under Version Information Type there are entries like comments, company name, file description and so on. What are these for?

Forgive my ignorance I realize this ain't rocket science. Maybe it's the triptophan kicking in.

thanks for any help
Hal



Edited by - Hal on 11/29/2003 7:57:44 PM

How Do I Get The ID (AutoNumber) To Automatically Increment A Number Sqlserver??URGE
I am having a problem using the INSERT statement in ASP.NET



I have a table "Information" with the following :



Name

Email

Comments

ID (Auto Number)



I have the following insert statement



Insert into Information VALUES (MyName,Email@My.com,MyComments);

How do I get the ID ( Auto Number ) to automatically increment a number.??
i am using SQL SERVER 2000

How Do I Get The ID (AutoNumber) To Automatically Increment A Number Sqlserver??URGE
no..sql server is not handling it..
Actualyy i am doing this in ASP.NET

In my table design i have ID in the first coloumn.
Actually in my form design there are only 3 feilds like Name,Email,Comments. and a submit button.

so in my coding part i have written my sql statement like this:

sqlInsert=INSERT INTO TblTran (TRFP_Name,TTRFP_EMail,TTRFP_Comments)

so how do i get my ID in the first coloumn of the datatable??

in query analyzer when initially the value of the ID is showing NULL

so how to increment this NULL value?

* RESOLVED * Setting A Slider Control To Increment In 0.05
How I can change the value of how much the slider control increments on each notch? At the moment, it's 1.

I want my slider to start at 0.00 then 0.05 then 0.10 etc...up to the value of 1.00 (20 notch movements in total).

I'm using the slider from common controls 6.

Thanks.

Number Verses Auto Number - With An Add/Update Query.
Hi there,
I would like to use Number and NOT the normal AUTO NUMBER. But I have a mayor problem as always the same error message comes up and therefor I can't SAVE the data.

Would anybody be able to help.

Thanks aktell

Runtime error'-2147467259(80004005)':
Operation must use Updateable query.


Code:
Private Sub ctl_GButton4_Click()
'---
'--- SAVE.
Set Cmd = New ADODB.Command

With Cmd
.ActiveConnection = ConRost
.CommandType = adCmdStoredProc

If bAdd Then
.CommandText = "sp_Add_Rostering"
Else
.CommandText = "sp_Edit_Rostering"
'--- Originaly used with Auto Number.
' .Parameters.Append cParam("@iBookingDate_ID", _
adInteger, Rs_Rostering.Fields("BookingDate_ID"))
End If

'--- The first line I used as I like to use NO AUTO NUMBER, but use _
NUMBER as ID field.
.Parameters.Append cParam("@iBookingDate_ID", adInteger, _
SetText(Me.txt_BookingDate_ID.Text))
.Parameters.Append cParam("@iClientID", adInteger, _
SetText(Me.txt_ClientID.Text))
.Parameters.Append cParam("@sClientName", adVarChar, _
SetText(Me.txt_NameRostClient.Text), 50)
.Parameters.Append cParam("@iCarerID", adInteger, _
SetText(Me.txt_CarerID.Text))
.Parameters.Append cParam("@sCarerName", adVarChar, _
SetText(Me.txt_NameRostCarer1.Text), 50)
.Parameters.Append cParam("@iBookingTime_ID", adDBTime, _
SetText(Me.txt_BookingTime_ID.Text))
.Execute
End With

Rs_Rostering.Requery
bAdd = False

'--- Date for the grid.
Set Me.DataGrid1.DataSource = Rs_Rostering

End Sub

Private Sub GetValues()
With Me
.txt_BookingDate_ID.Text = _
GetText(Rs_Rostering.Fields("BookingDate_ID"))
.txt_ClientID.Text = GetText(Rs_Rostering.Fields("Client_ID"))
.txt_NameRostClient.Text = _
GetText(Rs_Rostering.Fields("ClientName"))
.txt_CarerID.Text = GetText(Rs_Rostering.Fields("Carer_ID"))
.txt_NameRostCarer1.Text = _
GetText(Rs_Rostering.Fields("CarerName"))
.txt_BookingTime_ID.Text = _
GetText(Rs_Rostering.Fields("BookingTime_ID"))
End With
End Sub

Code:
sp_Add_Rostering:

PARAMETERS [@iBookingDate_ID] Long, [@iClientID] Long, _
[@sClientName] Text ( 50 ), [@iCarerID] Long, [@sCarerName] _
Text ( 50 ), [@iBookingTime_ID] Long;
INSERT INTO tbl_June ( BookingDate_ID, Client_ID, ClientName, _
Carer_ID, CarerName, BookingTime_ID )
VALUES ([@iBookingDate_ID], [@iClientID], [@sClientName], _
[@iCarerID], [@sCarerName], [@iBookingTime_ID]);


[color=Red]sp_Edit_Rostering:[/COLOR]

PARAMETERS [@iBookingDate_ID] Long, [@iClientID] Long, _
[@sClientName] Text ( 255 ), [@iCarerID] Long, [@sCarerName] _
Text ( 255 ), [@iBookingTime_ID] Long;
UPDATE tbl_June Set tbl_June.Client_ID = [@iClientID], _
tbl_June.ClientName = [@sClientName], tbl_June.Carer_ID = _
[@iCarerID], tbl_June.CarerName = [@sCarerName], _
tbl_June.BookingTime_ID = [@iBookingTime_ID]
WHERE (((tbl_June.BookingDate_ID)=[@iBookingDate_ID]));

Number Verses Auto Number - With An Add/Update Query.
Hi there,
I would like to use Number and NOT the normal AUTO NUMBER. But I have a mayor problem as always the same error message comes up and therefor I can't SAVE the data.

Would anybody be able to help.

Thanks aktell

Runtime error'-2147467259(80004005)':
Operation must use Updateable query.

Code:
Private Sub ctl_GButton4_Click()
'---
'--- SAVE.
    Set Cmd = New ADODB.Command
    
    With Cmd
      .ActiveConnection = ConRost
      .CommandType = adCmdStoredProc
      
      If bAdd Then
        .CommandText = "sp_Add_Rostering"
      Else
        .CommandText = "sp_Edit_Rostering"
'--- Originaly used with Auto Number.
        '.Parameters.Append cParam("@iBookingDate_ID", _
            adInteger, Rs_Rostering.Fields("BookingDate_ID"))
      End If
      
'--- The first line I used as I like to use NO AUTO NUMBER, but use _
          NUMBER as ID field.
      .Parameters.Append cParam("@iBookingDate_ID", adInteger, _
          SetText(Me.txt_BookingDate_ID.Text))
      .Parameters.Append cParam("@iClientID", adInteger, _
          SetText(Me.txt_ClientID.Text))
      .Parameters.Append cParam("@sClientName", adVarChar, _
          SetText(Me.txt_NameRostClient.Text), 50)
      .Parameters.Append cParam("@iCarerID", adInteger, _
          SetText(Me.txt_CarerID.Text))
      .Parameters.Append cParam("@sCarerName", adVarChar, _
          SetText(Me.txt_NameRostCarer1.Text), 50)
      .Parameters.Append cParam("@iBookingTime_ID", adDBTime, _
          SetText(Me.txt_BookingTime_ID.Text))
      .Execute
    End With
    
    Rs_Rostering.Requery
    bAdd = False
    
    '--- Date for the grid.
    Set Me.DataGrid1.DataSource = Rs_Rostering
    
End Sub

Private Sub GetValues()
    With Me
      .txt_BookingDate_ID.Text = _
          GetText(Rs_Rostering.Fields("BookingDate_ID"))
      .txt_ClientID.Text = GetText(Rs_Rostering.Fields("Client_ID"))
      .txt_NameRostClient.Text = _
          GetText(Rs_Rostering.Fields("ClientName"))
      .txt_CarerID.Text = GetText(Rs_Rostering.Fields("Carer_ID"))
      .txt_NameRostCarer1.Text = _
          GetText(Rs_Rostering.Fields("CarerName"))
      .txt_BookingTime_ID.Text = _
          GetText(Rs_Rostering.Fields("BookingTime_ID"))
    End With
End Sub

Code:
sp_Add_Rostering:

PARAMETERS [@iBookingDate_ID] Long, [@iClientID] Long, _
    [@sClientName] Text ( 50 ), [@iCarerID] Long, [@sCarerName] _
    Text ( 50 ), [@iBookingTime_ID] Long;
INSERT INTO tbl_June ( BookingDate_ID, Client_ID, ClientName, _
    Carer_ID, CarerName, BookingTime_ID )
VALUES ([@iBookingDate_ID], [@iClientID], [@sClientName], _
    [@iCarerID], [@sCarerName], [@iBookingTime_ID]);


sp_Edit_Rostering:

PARAMETERS [@iBookingDate_ID] Long, [@iClientID] Long, _
    [@sClientName] Text ( 255 ), [@iCarerID] Long, [@sCarerName] _
    Text ( 255 ), [@iBookingTime_ID] Long;
UPDATE tbl_June Set tbl_June.Client_ID = [@iClientID], _
    tbl_June.ClientName = [@sClientName], tbl_June.Carer_ID = _
    [@iCarerID], tbl_June.CarerName = [@sCarerName], _
    tbl_June.BookingTime_ID = [@iBookingTime_ID]
WHERE (((tbl_June.BookingDate_ID)=[@iBookingDate_ID]));

Increment Access Table
Hello
I hope this is coherent it's about 4am. Anyway, I've been working on getting MS Chart to show data from an Access db. To get it to work I just put numbers in the columns but I really need to be able to increment the values. My program holds records for memory modules that are built but fail test then go to repair. So it has serial numbers, repair status etc. It uses error codes from 10000 to 15000 for ex. Is there a way to increment the table with each new entry (record) made into the database?

I am using VB6 with Access 2k.

Hal

Copyright 2005-08 www.BigResource.com, All rights reserved