Can anyone please help as I am getting the error in the attached file ... and below is the code for reference. I have changed the columnnames and tablenames so please ignore that..
can anyone let me know what the issue is ...thanks for your time
ODBC "call failed"
[Microsoft][ODBC Sql Server Driver] [SQL Server] Violation of Unique Constraint "xxxx". Cannot insert duplicate key in object (tbldetails) (#2627) [Microsoft][ODBC Sql Server Driver] [SQL Server] The statement has been terminated(#3621)
Private Sub Add_Click()
On Error GoTo Err_msg:
strSysUserdt = Trim(UName())
Dim strSQLGroup As String
Dim rstConn As ADODB.Recordset
'Select Statement to get the my group
strSQLGroup = _
" SELECT tblS.UName, tblS.SUserName, tblS.Cust, tblU.hGrp " & _
" FROM tblS INNER JOIN tblU ON tblS.UserName = tblU.UName " & _
" WHERE ((tblS.SUserName)= '" & strSysUserdt & "')"
'Open Connection for my group
Set rstConn = New ADODB.Recordset
rstConn.Open strSQLGroup, CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdText
Select Case Me.lhStatus.Value
Case "is not closed"
If (rstConn!fcGroup = "my") Then
Me.sfrmDetails.Enabled = True
MsgBox "Your are not authorized to add any records", vbOKOnly, "No Privs!"
MsgBox "You can not add records, GSB is closed", vbOKOnly, "GSB Closed"
MsgBox "Invalid Status", vbInformation, "Error"