Let's first deal with the problem of the values entered into the Task Number, TT Impacted and Time controls in the form not being inserted into the columns in the Issues table. The form should have as its RecordSource property either the name of the Issues
table or a query which returns al the columns from the table. Using a query is generally better as it allows you to order the records on one or more columns so that they appear in a logical order in the form.
Within the form you should have controls, text boxes in this case, whose ControlSource property is in each case the name of the relevant column in the table, i.e. Task Number, TT Impacted or Time. Note however that naming a column Time is not a good idea as
Time is the name of a built in function, so as a 'reserved' word should be avoided as an object name. Something more specifically descriptive like CR_Time or similar would be better.
You should then have no difficulty entering data into the controls and it being assigned to the relevant column in the current row in the table when the form is close, you move to another record or otherwise explicitly save the record.
As regards the CR Workgroup column in the Issues table, the first question to be addressed is whether that column is either necessary or desirable. As I said in my first reply this depends on whether it is functionally determined by the contact or not. What
this means is that when you select a contact as the CR Raiser should the value of CR Workgroup in the Issues table always be the value of Workgroup in the row in the Contacts table for the selected contact? Or is it legitimate for the value of CR Workgroup
in the Issues table to differ from that value? If the former then you don't need the column in Issues and should return the value from Contacts in a computed control as I described in my earlier post, changing the column names in the combo box's RowSource
property to the actual names. BTW I should have mentioned that the CR Raiser's combo box's ColumnCount property should be changed to 3 in this scenario.
If on the other hand the value can legitimately differ from the value in Contacts you will need to address a fundamental design issue in your database. You will firstly need to introduce a Workgroups table if you do not currently have one. This will be a
table with one row for each possible workgroup, so would be set up like this:
WorkGroups
....WorkgroupID (PK)
....Workgroup
The primary key WorkgroupID column can for convenience be an autonumber.
Before doing anything further back up the database.
You then need to fill this table with the names of all workgroups currently listed in Contacts, using the following append query:
INSERT INTO Workgroups(Workgroup)
SELECT DISTINCT Workgroup
FROM Contacts
WHERE Workgroup IS NOT NULL;
You next need to add a WorkGroupID column, of long integer data type, to Contacts and insert values into it with the following update query:
UPDATE Contacts INNER JOIN Workgroups
ON Contacts.Workgroup = Workgroups.Workgroup
SET Contacts.WorkgroupID = Workgroups.WorkgroupID;
Once you are happy that the new WorkgroupID column in Contacts has the correct values you can delete the redundant Workgroup column from Contacts. Then create a relationship beteen Contacts and Workgroups and enforce referential integrity.
Whether or not you need a Workgroup column in Contacts as discussed above, you should do the above in any case; it's just a matter of good database design.
If on the basis of the discussion above you conclude that a CR Workgroup column is legitimately required in the Issues table, this should be of a long integer data type and its bound control in the issues form should be a combo box set up as follows:
RowSource: SELECT WorkgroupID, Workgroup FROM Workgroups ORDER BY Workgroup;
BoundColumn: 1
ColumnCount: 2
ColumnWidths: 0cm
If your units of measurement are imperial rather than metric Access will automatically convert the last one. The important thing is that the dimension is zero to hide the first column.
For selecting a workgroup in a contacts form you'd use a combo box set up in the same way.
To enter a workgroup not currently represented in the Workgroups table you can out the following code in the NotInList event procedures of the workgroup combo boxes in both the issues and contacts forms:
Dim ctrl As Control
Dim strSQL As String, strMessage As String
Set ctrl = Me.ActiveControl
strMessage = "Add " & NewData & " to list?"
strSQL = "INSERT INTO Workgroups(Workgroup) VALUES(""" & _
NewData & """)"
If MsgBox(strMessage, vbYesNo + vbQuestion) = vbYes Then
CurrentDB.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
ctrl.Undo
End If
When the user types a new workgroup name into the combo box and confirms it at the prompt, a new row will be inserted into the Workgroups table and the combo box's list updated to show the new workgroup.