The following code worked great until I split the database to an Access FE/BE.
Code hangs at highlight in debugger
Is it because the:
Set DB = currentDb is no longer correct ?
or something else I need to do.
Code hangs at highlight in debugger
Is it because the:
Set DB = currentDb is no longer correct ?
or something else I need to do.
Code:
Private Sub cmd_AddDistributionEmails_Click()
Dim API As String
'Check to make sure proper API is selected
If Forms![Main Form]!cbo_SelectWell = "" Then
MsgBox ("You Must Select a Well To Add a Well Contact")
Exit Sub
End If
'Check to make sure Wells are selected
If IsNull(Forms![Main Form]!cbo_SelectWell) Or Forms![Main Form]!cbo_SelectWell = "" Then
MsgBox ("You Must Select a Well To Add a Well Contact")
Exit Sub
Else
API = Forms![Main Form]!cbo_SelectWell.Column(0)
End If
'Get Ready to Insert Recordsnz
Dim DB As DAO.Database
Dim rs As DAO.Recordset
'Start code to add records to "data_WellContacts"
Dim item As Integer
Dim Cri, LBx As ListBox, itm, Build As String, DQ As String
Set LBx = Forms![Main Form]![lst_SelectDistributionEmails]
Set DB = CurrentDb
Set rs = DB.OpenRecordset("data_DistributionEmails")
With rs
For Each itm In LBx.ItemsSelected
[highlight].Index = "PrimaryKey"[/highlight]
.Seek "=", LBx.Column(0, itm), API
If rs.NoMatch Then
.AddNew
!API = API
!DistributionEmail_ID = LBx.Column(0, itm)
!Name = LBx.Column(1, itm)
!Email = LBx.Column(2, itm)
!CompanyName = LBx.Column(3, itm)
!DateCreated = Now()
!UserCreated = fOSUserName()
.Update
.Bookmark = rs.LastModified
Else
MsgBox "API='" & API _
& "' ContactName = '" & LBx.Column(2, itm) _
& "' Previously entered record"
End If
Next
End With
rs.Close
Me.Refresh
Forms![Main Form]![Frm_DistributionEmails].Form.Requery
'
Exit_cmd_AddDistributionEmails_Click:
Set DB = Nothing
Exit Sub
Err_cmd_AddDistributionEmails_Click:
MsgBox Err.Description
Resume Exit_cmd_AddDistributionEmails_Click
End Sub