M
Marshall P at Falkirk
I am using a piece of code to write new codes from a third paty system into
access. The code works fine when a single code is updated, however when more
than one code is selected the routine does not work.
The code I am using is as follows
Private Sub cmdAddSC_Click()
On Error GoTo Err_cmdAddSC_Click
Dim rec As Recordset
Dim strmsg As String
Dim stDocName As String
Set db = CurrentDb()
Set rec = db.OpenRecordset("tblCCBudget")
stDocName = "frmCodeEntry"
DoCmd.OpenForm stDocName
rec.Index = "PrimaryKey"
rec.Seek "=", Forms!frmCodeEntry!Text1
If rec.NoMatch = False Then
MsgBox ("This code already exists")
DoCmd.Close acForm, stDocName
Exit Sub
Else
DoCmd.OpenQuery "qryAddMissingCodesSC"
DoCmd.GoToControl "cmdCloseAddCode"
End If
Exit_cmdAddSC_Click:
Exit Sub
Err_cmdAddSC_Click:
MsgBox Err.Description
Resume Exit_cmdAddSC_Click
End Sub
access. The code works fine when a single code is updated, however when more
than one code is selected the routine does not work.
The code I am using is as follows
Private Sub cmdAddSC_Click()
On Error GoTo Err_cmdAddSC_Click
Dim rec As Recordset
Dim strmsg As String
Dim stDocName As String
Set db = CurrentDb()
Set rec = db.OpenRecordset("tblCCBudget")
stDocName = "frmCodeEntry"
DoCmd.OpenForm stDocName
rec.Index = "PrimaryKey"
rec.Seek "=", Forms!frmCodeEntry!Text1
If rec.NoMatch = False Then
MsgBox ("This code already exists")
DoCmd.Close acForm, stDocName
Exit Sub
Else
DoCmd.OpenQuery "qryAddMissingCodesSC"
DoCmd.GoToControl "cmdCloseAddCode"
End If
Exit_cmdAddSC_Click:
Exit Sub
Err_cmdAddSC_Click:
MsgBox Err.Description
Resume Exit_cmdAddSC_Click
End Sub