Multi-field Primary key and subform

sparkyrose

Registered User.
Local time
Yesterday, 19:55
Joined
Sep 12, 2007
Messages
31
Hi All,

I posted this in the Forms group on Friday and was advised to repost more simply. I also decided that I think this is a table/new record issue more than a form one.

This Db assists with an annual mailing requesting certifications from vendors. I want to be able to click the blue button on "Certification" tab (which contains a subform), to add a certification record for that vendor. The process currently runs without giving an error, but the built-in warnings tell me I'm updating 0 rows.

I wonder if the cause is that this has a multi-field PK on the main table. The "certification" subform has master/child links to the main, but only on one of the fields comprising the PK.

Any thoughts appreciated. Let me know what additional info you might need.
 
Was supposed to have attached the Db to this in the original post. Trying again here.
 

Attachments

Thanks for the reply. That alone didn't fix it, however. I'm not sure why. In any case, I needed to request input from the user to establish the new record. I found something else online and set it up this way:

Code:
Private Sub btnAddSingleRec_Click()

Dim db As Database
Dim rs As DAO.Recordset
Dim strCertYear As String
Dim strNetwork As String
Dim strContract As String

 Set db = CurrentDb
 Set rs = db.OpenRecordset("CurrentProcess")
  
 strCertYear = Trim(InputBox( _
 "Enter Cert Year"))
 strNetwork = Forms!frmMainForm!Network
 strContract = Forms!frmMainForm!Contract
 
 If strCertYear <> "" Then
 
 ' Call the function that adds the record.
 AddYear rs, strCertYear, strNetwork, strContract
  
 Else
 Debug.Print _
 "You must input the Cert Year!"
 End If

End Sub

Which references this Function:

Code:
Function AddYear(rstTemp As Recordset, _
 strYear As String, strNtwk As String, strK As String)
 
 ' Adds a new record to a Recordset using the data passed
 ' by the calling procedure. The new record is then made
 ' the current record.
 With rstTemp
 .AddNew
 !CertYear = strYear
 !Network = strNtwk
 !Contract = strK
 .Update
 .Bookmark = .LastModified
 End With
 
End Function

This is now solved!
 

Users who are viewing this thread

Back
Top Bottom