The code is as follows:
Private Sub cmd_ScopeID_Click()
Dim db As Database
Dim rst As Recordset
Dim i As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("tdatScope")
While Not rst.EOF
If IsNull(rst!scopeID) Then
rst!scopeID = Nz(DMax("[scopeID]", "tdatScope", "[room]= '" & rst!room & "'") + 1, _
[DLookup("roomOrder", "tdatRooms", "[room]='" & rst!room & "'") * 1000])
End If
rst.MoveNext
Wend
End Sub
I have basically learned Access by trial and error. So I think there's something I just don't understand about parsing through the database and using the DMax function. The routine is just supposed to find the next possible ID value for a given room if the field is blank. I have tried several variations of this code, but it only changes which error comes up.
scopeID and room are both fields within tdatScope.
Any help would be appreciated.
Private Sub cmd_ScopeID_Click()
Dim db As Database
Dim rst As Recordset
Dim i As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("tdatScope")
While Not rst.EOF
If IsNull(rst!scopeID) Then
rst!scopeID = Nz(DMax("[scopeID]", "tdatScope", "[room]= '" & rst!room & "'") + 1, _
[DLookup("roomOrder", "tdatRooms", "[room]='" & rst!room & "'") * 1000])
End If
rst.MoveNext
Wend
End Sub
I have basically learned Access by trial and error. So I think there's something I just don't understand about parsing through the database and using the DMax function. The routine is just supposed to find the next possible ID value for a given room if the field is blank. I have tried several variations of this code, but it only changes which error comes up.
scopeID and room are both fields within tdatScope.
Any help would be appreciated.