Question : If record count is 0 then enter value in field

Hi,

I'm trying to assign a line number using a record count in VBA. The form is bound to a temp table so when it comes up there are never any records in it.  What I would like to do is start the number sequence off at 1 and then assign numbers after that.  What is occur using this code is that it will always start with 2 and then work correclty after that.  
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
Dim db As Database
    Dim rst As Recordset
    Dim strSQL As String
    Dim rstRecCount As Long
    Dim rstValue As Long
    
    Set db = CurrentDb
    strSQL = "Select * from tmp_SODetail;"
    Set rst = db.OpenRecordset(strSQL)
    rstRecCount = rst.RecordCount
    
        If rstRecCount = 0 Then
            ' There were no records
            rstValue = 1
        Else
            ' records exist
            rst.MoveLast
            rstValue = rst.RecordCount + 1
        End If
    Me!SOLine.Value = rstValue
Open in New Window Select All

Answer : If record count is 0 then enter value in field

This is how I got it to work if anyone is interested.  It now starts the number off at 001 and then counts from their.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
Set db = CurrentDb
    strSQL = "Select * from tmp_SODetail;"
    Set rst = db.OpenRecordset(strSQL)
    rstRecCount = rst.RecordCount
    CurrentCount = DCount("*", "tmp_SODetail")
            
        If CurrentCount = 1 Then
            ' There were no records
            rstValue = 1
        Else
            ' records exist
            rst.MoveLast
            rstValue = rst.RecordCount
        End If
    Me!SOLine.Value = Format(rstValue, "000")
Open in New Window Select All
Random Solutions  
 
programming4us programming4us