Counter is not a data type in access. You probably want as integer or as long. Also, why use variable name smith? Usually people use intI, lngI, or just i.
Counter was (and still is) a data type used with SQL Create Table.
Here is info from FunctionX
To support this, Microsoft Access SQL supports two data types named COUNTER and AUTOINCREMENT. Here is an example of applying the COUNTER data type to a field:
Private Sub cmdTable_Click()
DoCmd.RunSQL "CREATE TABLE Contractors(" & _
"ContractorNo COUNTER, " & _
"FullName TEXT NOT NULL);"
End Sub
Sub testSQLx()
Dim x As String
x = "CREATE TABLE ContractorsXXTEST(" & _
"ContractorNo COUNTER, " & _
"FullName TEXT NOT NULL);"
Dim db As DAO.Database
Set db = CurrentDb
db.Execute x, dbFailOnError
End Sub
I am using smith and many other names so I know who's data I am picking up.
integer or long, ok i'll try long thanks. I recall reading somewhere there can be a problem using integer.
Interger will cause a problem if you expect the counter to get very large. In that case, use long. If you are not sure how big it would be use long. Be conservative and assume the counter will sometimes be larger than you expect unless you are sure. For more information, look up number types in MS Access and find out how large a number each data type can hold.