Hans kindly wrote some code a while back, and it's been working all right up until recently. It's currently producing an error message, although the code still actually executes, so this is more of an annoyance than anything else.
Would anyone know whether it's just that Access needs a Compact & Repair, or is there a simple workaround?
The Code is as follows:
Code: Select all
Private Sub cmdAdd_Click()
Dim lngGraduateID As Long
Dim sql As String
Dim stDocName As String
Dim stLinkCriteria As String
On Error GoTo sbCreateReviews_Error
' ***** Save the record if necessary *****
If Me.Dirty Then Me.Dirty = False
sql = "INSERT INTO tblGAP (GraduateID, GAPstaff_FK, LC, ReferralDate) Values (" & GraduateID & _
", " & GAPstaff_FK & ", " & LC & ", #" & Format(ReferralDate, "yyyy/mm/dd") & "#)"
CurrentDb.Execute sql
stDocName = "frmGAP"
stLinkCriteria = "[GraduateID]=" & Me![GraduateID]
DoEvents
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit Sub
sbCreateReviews_Error:
If Err.Number = 3022 Then
Resume Next
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Add Graduate "
End If
End Sub
A normal select Query would look like this, where the 2 Tables are joined:
SELECT tblGraduate.GraduateID, tblGAP.GraduateID
FROM tblGraduate INNER JOIN tblGAP ON tblGraduate.GraduateID = tblGAP.GraduateID;
If there's a quick fix, eg, just inserting the Table name before the field, that'd be great.
Thanks in advance for any help.