> dmax("[index]","[song]", "[albumID]=" & forms!myform!albumID)+1
Nz(dmax("[index]","[song]", "[albumID]=" & forms!myform!albumID),0)+1
As the first one will return a null.
or (not sure but try)
Nz(dmax("[index]","[song]", "[albumID]=" & form.Parent!albumID),0)+1
would be portable to another form.

Signature
This sig left intentionally blank
Elliot W. Scott - 17 Feb 2005 17:38 GMT
>> dmax("[index]","[song]", "[albumID]=" & forms!myform!albumID)+1
>
[quoted text clipped - 3 lines]
> Nz(dmax("[index]","[song]", "[albumID]=" & form.Parent!albumID),0)+1
> would be portable to another form.
I think something is wrong I get an #error
I don't know what this is.
\/
Nz(dmax("[index]","[song]", "[albumID]=" & form.Parent!albumID),0)+1
Is [song] my Song table? or should it be the song id?
Elliot W. Scott - 17 Feb 2005 17:38 GMT
>> dmax("[index]","[song]", "[albumID]=" & forms!myform!albumID)+1
>
[quoted text clipped - 3 lines]
> Nz(dmax("[index]","[song]", "[albumID]=" & form.Parent!albumID),0)+1
> would be portable to another form.
I think something is wrong I get an #error
I don't know what this is.
\/
Nz(dmax("[index]","[song]", "[albumID]=" & form.Parent!albumID),0)+1
Is [song] my Song table? or should it be the song id?
Elliot W. Scott - 17 Feb 2005 17:39 GMT
>> dmax("[index]","[song]", "[albumID]=" & forms!myform!albumID)+1
>
[quoted text clipped - 3 lines]
> Nz(dmax("[index]","[song]", "[albumID]=" & form.Parent!albumID),0)+1
> would be portable to another form.
I think something is wrong I get an #error
I don't know what this is.
\/
Nz(dmax("[index]","[song]", "[albumID]=" & form.Parent!albumID),0)+1
Is [song] my Song table? or should it be the song id?
Trevor Best - 17 Feb 2005 18:41 GMT
>>> dmax("[index]","[song]", "[albumID]=" & forms!myform!albumID)+1
>>
[quoted text clipped - 11 lines]
>
> Is [song] my Song table? or should it be the song id?
dmax(fieldname,tablename,criteria)
Yes, that should be your song table.
Also, where is this DMax being executed from?
Have you tried the:
Nz(dmax("[index]","[song]", "[albumID]=" & forms!myform!albumID),0)+1
approach?
If addressing the form from code, you should use Me instead of Form, e.g.
Nz(dmax("[index]","[song]", "[albumID]=" & Me.Parent!albumID),0)+1
Alternatively you should put this DMax into the DefaultValue property,
don't put in the ControlSource property, if you do it needs a "=" before
it and it won't save it anywhere.

Signature
This sig left intentionally blank
Elliot W. Scott - 17 Feb 2005 20:15 GMT
>>>> dmax("[index]","[song]", "[albumID]=" & forms!myform!albumID)+1
>>>
[quoted text clipped - 27 lines]
> don't put in the ControlSource property, if you do it needs a "=" before
> it and it won't save it anywhere.
Thanks. I had to do the it as follows:
=Nz(DMax("[index]","[Song]","[albumID]=" &[Forms]![AlbumForm]![id]),0)+1
but it still doesn't work, it does it in a weird pattern...
It does this for my index:
1
1
2
2
3
3
4
4
5
5
6
6
....
I think it does this because the new record is created before I am done
with the one I am currently creating. :(
Trevor Best - 17 Feb 2005 21:45 GMT
>>>>> dmax("[index]","[song]", "[albumID]=" & forms!myform!albumID)+1
>>>>
[quoted text clipped - 50 lines]
> I think it does this because the new record is created before I am done
> with the one I am currently creating. :(
Try requerying the index textbox in Form_BeforeInsert()

Signature
This sig left intentionally blank