Hello,
I have been successfully using a database I've created for several months to populate an equipment list for a project we've been working on. However, the form has recently stopped working for some unknown reason. I've been having a problem recently where one table (Project Info) keeps auto-incrementing when I try to create a new record with another table (Equipment Info). Only the Equipment table is supposed to grow. It used to never grow the project table, but now it is and I'm stumped as to what is causing it.
Here are the details of my tables:
Table 1: Project Info
-Supposed to only hold one record (a static table)
-ProjKey=1 (integer, primary key)... Required=No, Indexed=Yes (No duplicates)
-Holds misc. project information such as project title, job #, etc.
-Holds project specific information for equipment
-Users can edit project information in a separate form (which works fine)
Table 2: Equipment List Data
-Holds many records and can increase in records (a dynamic table)
-Holds misc. information about the equipment
-ItemNo=* (integer, primary key... grows through a form macro when user enters a new record, which has worked fine in the past)... Required=No, Indexed=Yes (No duplicates)
-ProjLink=1 (integer)... Default Value=1, Required=No, Indexed=No
Here is the details of my query:
-Equipment table ProjLink has 1 to 1 relationship with Project table ProjKey
-Shows all equipment fields
-Shows specific project related info from the project table related to the equipment (this should be static)
Here are a handful of the details of my form:
-Allow Filters = Yes, Allow Edits = Yes, Allow Deletions = Yes, Allow Additions = Yes, Data Entry = No, Recordset Type = Dynaset, Record Locks = No locks, Fetch Defaults = Yes
-The macro that increments ItemNo for the equipment executes on "Got Focus". The code is below...
Private Sub ItemNoBox_GotFo cus()
Dim strMsg As String
If Me!ItemNoBox.Va lue > 0 Then
Exit Sub 'we don't want to run this if something already exists
End If
Call incrNumber(Me, strMsg, "ItemNoBox" )
If strMsg <> vbNullString Then
MsgBox strMsg, vbInformation
End If
End Sub
-incrNumber uses recordset clone to see what the itemNo was for the last record, then increments it. This was done to circumvent the problem[autonumber] had with incrementing whenever a user hits "Esc" to cancel input into a form, or when a record must be deleted for whatever reason. Since autonumbers cannot be edited, I had to code it this way.
In the form, upon creating a new equipment, I then get the following message:
"The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again." I put a box that shows the ProjKey, and it has been changing when it shouldn't.
When I create records using the query, it does not have this problem. How can I fix my form? Or, how can I force my project table to never grow?
Thank you.
I have been successfully using a database I've created for several months to populate an equipment list for a project we've been working on. However, the form has recently stopped working for some unknown reason. I've been having a problem recently where one table (Project Info) keeps auto-incrementing when I try to create a new record with another table (Equipment Info). Only the Equipment table is supposed to grow. It used to never grow the project table, but now it is and I'm stumped as to what is causing it.
Here are the details of my tables:
Table 1: Project Info
-Supposed to only hold one record (a static table)
-ProjKey=1 (integer, primary key)... Required=No, Indexed=Yes (No duplicates)
-Holds misc. project information such as project title, job #, etc.
-Holds project specific information for equipment
-Users can edit project information in a separate form (which works fine)
Table 2: Equipment List Data
-Holds many records and can increase in records (a dynamic table)
-Holds misc. information about the equipment
-ItemNo=* (integer, primary key... grows through a form macro when user enters a new record, which has worked fine in the past)... Required=No, Indexed=Yes (No duplicates)
-ProjLink=1 (integer)... Default Value=1, Required=No, Indexed=No
Here is the details of my query:
-Equipment table ProjLink has 1 to 1 relationship with Project table ProjKey
-Shows all equipment fields
-Shows specific project related info from the project table related to the equipment (this should be static)
Here are a handful of the details of my form:
-Allow Filters = Yes, Allow Edits = Yes, Allow Deletions = Yes, Allow Additions = Yes, Data Entry = No, Recordset Type = Dynaset, Record Locks = No locks, Fetch Defaults = Yes
-The macro that increments ItemNo for the equipment executes on "Got Focus". The code is below...
Private Sub ItemNoBox_GotFo cus()
Dim strMsg As String
If Me!ItemNoBox.Va lue > 0 Then
Exit Sub 'we don't want to run this if something already exists
End If
Call incrNumber(Me, strMsg, "ItemNoBox" )
If strMsg <> vbNullString Then
MsgBox strMsg, vbInformation
End If
End Sub
-incrNumber uses recordset clone to see what the itemNo was for the last record, then increments it. This was done to circumvent the problem[autonumber] had with incrementing whenever a user hits "Esc" to cancel input into a form, or when a record must be deleted for whatever reason. Since autonumbers cannot be edited, I had to code it this way.
In the form, upon creating a new equipment, I then get the following message:
"The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again." I put a box that shows the ProjKey, and it has been changing when it shouldn't.
When I create records using the query, it does not have this problem. How can I fix my form? Or, how can I force my project table to never grow?
Thank you.
Comment