lukeargent
Technical User
I have a problem when using ADP connected to SQL Server 2000 that works fine when using a plain and simple MDB file.
I have a field that I want to increment based on the last value in the table but matching the linking field between the 2 tables.
I.E. a DVD could have 10 reviews of which it would appear as DVD_ID = 1, ReviewID = 1, 2, 3, 4 etc etc, and then DVD_ID = 2, ReviewID = 1, 2, 3, 4 etc etc. As you can see the ReviewID needs to revert back to 1 for every DVD_ID.
When using the MDB file, I create a button called btnNewID and give the following code on the "On_click" event;
me.ReviewID = nz(Dmax("ReviewID", "tbl_Review", "DVD_ID= " & Me.[DVD_ID]), 0) + 1
This works perfectly, but when I try to run whilst connected to the SQL server, I get error;
"invalid syntax near ')'."
Everything I've read suggests that the code doesn't support SQL Server and people are saying use a Stored Proc instead, but I'm new to SQL so I don't know anyway of creating this SP, and then calling it from a button on the form.
Has anyone been in a similar situation or at least know a way I can get around this? Help is much appriciated, I've lost a lot of hair the last couple of days!!
Kind Regards,
Luke Argent
IT Support Technician
I have a field that I want to increment based on the last value in the table but matching the linking field between the 2 tables.
I.E. a DVD could have 10 reviews of which it would appear as DVD_ID = 1, ReviewID = 1, 2, 3, 4 etc etc, and then DVD_ID = 2, ReviewID = 1, 2, 3, 4 etc etc. As you can see the ReviewID needs to revert back to 1 for every DVD_ID.
When using the MDB file, I create a button called btnNewID and give the following code on the "On_click" event;
me.ReviewID = nz(Dmax("ReviewID", "tbl_Review", "DVD_ID= " & Me.[DVD_ID]), 0) + 1
This works perfectly, but when I try to run whilst connected to the SQL server, I get error;
"invalid syntax near ')'."
Everything I've read suggests that the code doesn't support SQL Server and people are saying use a Stored Proc instead, but I'm new to SQL so I don't know anyway of creating this SP, and then calling it from a button on the form.
Has anyone been in a similar situation or at least know a way I can get around this? Help is much appriciated, I've lost a lot of hair the last couple of days!!
Kind Regards,
Luke Argent
IT Support Technician