1 to 1 Linked Form Problem

C

CJ

Hi Groupies:

I have a table with all employees (250 records) and another table with a
record of the certifcations they have received, (200 records). The
relationship is 1 to 1 based on the Employee Number. The Employee form has a
button to open the Certification form and the two forms are linked as
follows:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCertification"

stLinkCriteria = "[GIN Number]=" & "'" & Me![GIN Number] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

My problem is that when I open the certification form for an employee that
is not currently in it's underlying data source, an empty recordset appears.
I need access to create a new record in the Certification table and fill in
the correct Employee Number from the Employee table.

Hope this makes sense.
CJ
 
J

jleckrone

In the underlying code of your button, perfom a check to see if the
Employee exists in your table and then if not insert them. Something
like

If IsNull(Dlookup("Gin Number", "tblCertifications", "Gin Number = " &
Me.[GIN Number]) Then
'Record Missing, add it
Docmd.RunSQL "Insert Into TblCertifications([GIN Number]) Values(" &
Me.[GIN Number] & ");"
End IF

Open your form

Hope that helps!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top