![]() |
| ||
| Urgently need help in getting Autonumbering ID. Thanks Alot. Hi people, I need an urgent help in this. I have a form where I have created a textbox(disabled) in order to show the Number ID from the access database Auto ID but have a problem here. The newly created table in the database doesn't show any number example like it doesn't show No.1 in the 1st row of recordset if there is no data, it will only show the No.1 if there is data entered. I have a situation here where I need to open a new form to enter some data, when I open the form, it will be able to show No. 1 in the textbox and when I close the form, it will be able to enter the data in the table. I don't know whether am I clear enough. The table in the database looks like this when there is no data entered: AutoID Subject Date (New ID) (Blank) (Blank) If I manually entered some data in the 1st row, it will become like this: AutoID Subject Date 1 Testing 26/5/07 (New ID) (Blank) (Blank) So no matter what it just doesn't show the no. of the next recordset. Hope it's clear enough. Here is my code:
Thanks alot if there's any help provided. |
| ||
| Re: Urgently need help in getting Autonumbering ID. Thanks Alot. I don't know how to use the code wrap, please forgive me. |
| ||
| Re: Urgently need help in getting Autonumbering ID. Thanks Alot. Hi, If u r using VB6, Change this Line : Set RS = ADOConn.Execute("SELECT [ID] FROM Data;") To Set RS =Nothing RS.Open "SELECT Max(ID) FROM Data;",ADOConn If Not RS.EOF Then If Not Is Null(RS(0)) Then GetData =RS(0)+1 Else GetData=1 End If End If I hope It is Clear. If u r using VB6.. Why r u Late Binding the Objects? Directly use : Dim AdoConn As New ADODB.Connection Dim RS As New ADODB.RecordSet Regards Veena |
| ||
| Re: Urgently need help in getting Autonumbering ID. Thanks Alot. Hmm.. I'm not sure whether I'm using vb6 because I never do any vb programming before and I'm using for the outlook programming. What you mean by late binding? I try your codings out and post again if it'snot working. Thanks for your reply. |
| ||
| Re: Urgently need help in getting Autonumbering ID. Thanks Alot. Ok, your code has problem. 1st, RS required, 2nd, Syntax error "If Not Is Null(RS(0)) Then". I have to Set RS = ........... if not I will get the error msg "RS required" |
| All times are GMT -4. The time now is 6:32 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC