MSAccessRookie
AWF VIP
- Local time
- Today, 06:20
- Joined
- May 2, 2008
- Messages
- 3,428
I have a problem with Locking on one of my user input forms. The program uses an MS Access 2003 Front End and an SQL Server 2005 Back End to store the tables. The structure of the table being used, the query that is the recordsource for the form, and the code for the two methods of opening the form are all shown below. When multiple users try to add a user at the same time, we get intermittent deadlocks. This is not a normal procedure but it did happen several times on the initial testing day. Almost everything else was perfect, but this was a major problem issue (they called it a show-stopper level) for the users.
Users enter the form through one of two methods.
1. There is a button marked "Add Person" that calls the Macro below
2. A user can Double click on a name and also enter the form with the event code listed below.
One additional Point that may be of interest. I changed the form from "Form View" to "DataSheet View", and discovered that the query displays itself as having TWO AutoNumber Fields (Person_ID and Researcher). This has to be incorrect on at least two levels that I am aware of:
1. Access only allows one AutoNumber field per table, and all the values come from the same table.
2. While the Person_ID field is distinct for each record, has no NULL values, and is the Primary Key for the table, the Researcher Field contains duplicates and also contails NULL Values.
Does anyone have any Ideas as to how this is possible, and if it is in any way related to my problem?
-----------------------------------------------------------------------
TABLE
QUERY
MACRO
EVENT
Users enter the form through one of two methods.
1. There is a button marked "Add Person" that calls the Macro below
2. A user can Double click on a name and also enter the form with the event code listed below.
One additional Point that may be of interest. I changed the form from "Form View" to "DataSheet View", and discovered that the query displays itself as having TWO AutoNumber Fields (Person_ID and Researcher). This has to be incorrect on at least two levels that I am aware of:
1. Access only allows one AutoNumber field per table, and all the values come from the same table.
2. While the Person_ID field is distinct for each record, has no NULL values, and is the Primary Key for the table, the Researcher Field contains duplicates and also contails NULL Values.
Does anyone have any Ideas as to how this is possible, and if it is in any way related to my problem?
-----------------------------------------------------------------------
TABLE
Code:
[B][SIZE=3][B][FONT=Courier New]TABLE dbo.tblPeople([/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]Person_ID int IDENTITY(1,1) [COLOR=red]NOT NULL[/COLOR],[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]Researcher nvarchar(255) [COLOR=red]NULL[/COLOR],[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]L_Name nvarchar(50) [COLOR=red]NULL[/COLOR],[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]F_Name nvarchar(50) [COLOR=red]NULL[/COLOR],[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]M_Initial nvarchar(50) [COLOR=red]NULL[/COLOR],[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]Title nvarchar(50) [COLOR=red]NULL[/COLOR],[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]CommonName nvarchar(50) [COLOR=red]NULL[/COLOR],[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]Notes nvarchar(max) [COLOR=red]NULL[/COLOR],[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]email nvarchar(50) [COLOR=red]NULL[/COLOR],[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]DateAdded datetime [COLOR=red]NULL[/COLOR],[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]SSMA_TimeStamp timestamp NOT [COLOR=red]NULL[/COLOR])[/FONT][/B][/SIZE][/B]
QUERY
Code:
[B][SIZE=3][B][FONT=Courier New]SELECT [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]IIf(IsNull(L_Name),"",L_Name) & [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] IIf(IsNull(L_Name),"",IIf(IsNull(F_Name),"",", ")) & [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] IIf(IsNull(F_Name),"",F_Name) AS Expr1, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]Person_ID, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]Researcher, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]DateAdded, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]Title, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]F_Name, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]M_Initial, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]L_Name, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]email, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]Notes, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]IIf(IsNull(Title),"",Title & " ") & [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] IIf(IsNull(F_Name),"",F_Name & " ") [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] L_Name AS FormalName, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]IIf(Not (IsNull(F_Name)),F_Name & " ",Title & " ") & [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] L_Name AS SemiFormalName, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]CommonName, [/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]SSMA_TimeStamp[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]FROM tblPeople[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]ORDER BY 1;[/FONT][/B][/SIZE][/B]
MACRO
Code:
[B][SIZE=3][B][FONT=Courier New]Macro Name: AddPerson[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New][B][SIZE=3][B][FONT=Courier New] Statement1: OpenForm[/FONT][/B][/SIZE][/B]
[/FONT][/B][/SIZE][/B][B][SIZE=3][B][FONT=Courier New][B][SIZE=3][B][FONT=Courier New][B][SIZE=3][B][FONT=Courier New] Statement2: GotoRecord[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] Statement3: GotoControl[/FONT][/B][/SIZE][/B]
Entended Definitions
OpenForm[/FONT][/B][/SIZE][/B]
Form Name fmrPeople[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] View Form[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] Window Mode Normal[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] GotoRecord[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] Record New[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] GotoControl[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] Control Name Title[/FONT][/B][/SIZE][/B]
EVENT
Code:
[B][SIZE=3][B][FONT=Courier New]Private Sub ResearcherID_DblClick(Cancel As Integer)[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]Dim rst As Recordset[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]DoCmd.OpenForm "fmrPeople", acNormal[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]If IsNull(Me.ResearcherID) Then[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] ' Start at the next available new record[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] DoCmd.GoToRecord , , acNewRec[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] ' Set the default date to the current date[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] ' and Position the cursor on the Title Field[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] Forms!fmrPeople.Form.DateAdded = Date[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] Forms!fmrPeople.Form.Title.SetFocus[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]Else[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] Set rst = Forms!fmrPeople.Form.RecordsetClone[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] rst.FindFirst "Person_ID = " & CStr(Me.ResearcherID.Column(1))[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] If Not rst.NoMatch Then[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] Forms!fmrPeople.Form.Bookmark = rst.Bookmark[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] Else[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] MsgBox CStr(Me.ResearcherID.Column(0)) & " Not Found!"[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] End If[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] ' Set the default date to the current date[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] ' and Position the cursor on the Title Field[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] Forms!fmrPeople.Form.DateAdded = Date[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] Forms!fmrPeople.Form.Title.SetFocus[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] rst.Close[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New] Set rst = Nothing[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]End If[/FONT][/B][/SIZE][/B]
[B][SIZE=3][B][FONT=Courier New]End Sub[/FONT][/B][/SIZE][/B]
Last edited: