- Local time
- Today, 15:27
- Joined
- Feb 26, 2007
- Messages
- 2
Can someone please help me? I have a table that hold territory assignments with a start dt and end dt. This table will help us determine when a certain user was assigned to a territory and should receive credit for work done on that territory during the date range based on the start and end dates. If an end dt is null then that record is the current existing assignment. it will only be end dated when the assignment is ending. I do not want any new records added until all records for that territory are end dated. I created a Add Records button on the form with the following script, but it isn't working. I have limited knowledge of VB. Any help would be appreciated.
Private Sub AddRecord_Click()
On Error GoTo Err_AddRecord_Click
Dim SQL As String
SQL = "Select [EndDt] from [tRCAAssignments] where [Territory] = [Forms]![fTerritoryAssignments]![Territory] and [EndDt] is not null"
If SQL Is Null Then
MsgBox "There are records that need to be end dated"
Else
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
End If
Exit_AddRecord_Click:
Exit Sub
Err_AddRecord_Click:
MsgBox Err.Description
Resume Exit_AddRecord_Click
End Sub
Private Sub AddRecord_Click()
On Error GoTo Err_AddRecord_Click
Dim SQL As String
SQL = "Select [EndDt] from [tRCAAssignments] where [Territory] = [Forms]![fTerritoryAssignments]![Territory] and [EndDt] is not null"
If SQL Is Null Then
MsgBox "There are records that need to be end dated"
Else
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
End If
Exit_AddRecord_Click:
Exit Sub
Err_AddRecord_Click:
MsgBox Err.Description
Resume Exit_AddRecord_Click
End Sub