this doesnt work either
Private Sub Form_Load()
Dim strDocName As String
Dim strNextNumber As String
strDocName = "General Housing Survey"
strNextNumber = Nz(DMax("ID", "General Housing Survey"), 0) + 1
strNextNumber = Me.ID
Forms(strDocName)!ID = strNextNumber
>Private Sub Form_Load()
>
[quoted text clipped - 10 lines]
>number and then increment it by 1 and then fill in the ID field
>automatically on the form with the new number opon it opening
You have the second line backwards. It should be:
Me.ID = strNextNumber
BUT, you do NOT want to do this unless you are certain that
the form is on a new record. It would be more than a little
disasterous to do that to an existing record.

Signature
Marsh
MVP [MS Access]
reservedbcreater - 27 Jan 2005 19:36 GMT
thank you it worked marshall
See responses inline below:
> Private Sub Form_Load()
>
> Dim strNextNumber As String
Are you sure you want this to be a string variable? If you're numerically
incrementing it, it might make more sense if it were a Long. What data type
is your ID field within the table?
> strNextNumber = Nz(DMax("ID", "General Housing Survey"), 0) + 1
I honestly don't know if it makes a difference in this context, but usually
when there are spaces within an object name, you should enclose the name in
brackets:
...DMax("ID", "[General Housing Survey]")...
> strNextNumber = Me.ID
I think you want this to be reversed, as in:
Me.ID = strNextNumber
otherwise, you're just overwriting your variable with the contents of the ID
field.
> End Sub
>
> ?????
> i want it to read the General Housing Table ID field and get the highest
> number and then increment it by 1 and then fill in the ID field
> automatically on the form with the new number opon it opening
Hope this helps,
Joe