Não tenho certeza .. mas você pode tentar isso ...
Private Sub KnopProjectVersturen_Click()
On Error GoTo ErrProc
'This is the first part of the code checking if the subform has been filled in
If IsNull(Me!Subform_OMnummers.Form!Omnr) Then
MsgBox("Vul het OMnummer in. Je kan het project niet exporteren zonder OMnummer.")
Exit Sub
End If
'This is the second part of the code, checking if the record exists in the other table and then copying part of the record
DoCmd.OpenQuery "Qry_Depo_ControleAanwezig"
If DCount("Deponering.projectnummer", "Qry_Depo_ControleAanwezig") = 0 Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "Qry_projectnaarDepot"
DoCmd.OpenQuery "Qry_ToevoegProjectDepot"
DoCmd.OpenForm "Depot_uitvoer", , , "[Projectnummer] = '" & Me![Projectnummer] & "' And [subID]=[subID]"
Me.Status = 8
DoCmd.Close acQuery, ("Qry_Depo_ControleAanwezig")
DoCmd.SetWarnings True
Else
MsgBox "Dit project bestaat al in de Depot_Uitvoer, verander de status in het projectformulier", vbInformation, "Example"
DoCmd.Close acQuery, ("Qry_Depo_ControleAanwezig")
End If
'Als er fouten zijn laat deze code een messagebox zien met het nummer en de melding.
ExitProc:
Exit Sub
ErrProc:
Select Case Err.Number
Case Else
MsgBox Err.Number & "--" & Err.Description
Resume ExitProc
End Select
End Sub