J
Jack
Dim db As DAO.Database
Dim rstApp As DAO.Recordset
Dim strSql As String
Dim strContact As String
Dim strPhone As String
Dim strEmail As String
Dim strFax As String
Dim strNotes As String
If (IsNull(Me.txtContact) = True) Or (Me.txtContact = "") Then
MsgBox ("You need to add the contact name at the minimum to add new contact")
Exit Sub
Else
strContact = Trim(Me.txtContact)
If (IsNull(Me.txtContactPhone) = True) Then
strPhone = ""
Else
strPhone = Trim(Me.txtContactPhone)
End If
If (IsNull(Me.txtContactEmail) = True) Then
strEmail = ""
Else
strEmail = Trim(Me.txtContactEmail)
End If
If (IsNull(Me.txtFax) = True) Then
strFax = ""
Else
strFax = Trim(Me.txtFax)
End If
If (IsNull(Me.txtContactNotes) = True) Then
strNotes = ""
Else
strNotes = Trim(Me.txtContactNotes)
End If
Set db = CurrentDb
Set rstApp = db.OpenRecordset("tblContacts", dbOpenDynaset, dbSeeChanges)
With rstApp
..AddNew
!Contact = strContact
!Phone = strPhone
![E-mail] = strEmail ' Not showing value when hovering my mouse on ![E-mail]
!Fax = strFax
!Notes = strNotes
' ' DoCmd.GoToRecord , , acNewRec
..Update
MsgBox ("Record added to the system")
End With
Dim strDocName As String
strDocName = "frmActionRequestFiltered"
If IsLoaded(strDocName) Then
Forms(strDocName)!cboContacts.Requery
End If
strDocName = "frmActionRequest"
If IsLoaded(strDocName) Then
Forms(strDocName)!cboContacts.Requery
End If
Me.txtContact = ""
Me.txtContactPhone = ""
Me.txtContactEmail = ""
Me.txtFax = ""
Me.txtContactNotes = ""
End If
rstApp.Close
Set rstApp = Nothing
Set db = Nothing
Exit_btnAdd_Click:
Exit Sub
Err_btnAdd_Click:
MsgBox Err.Description
Resume Exit_btnAdd_Click
Dim rstApp As DAO.Recordset
Dim strSql As String
Dim strContact As String
Dim strPhone As String
Dim strEmail As String
Dim strFax As String
Dim strNotes As String
If (IsNull(Me.txtContact) = True) Or (Me.txtContact = "") Then
MsgBox ("You need to add the contact name at the minimum to add new contact")
Exit Sub
Else
strContact = Trim(Me.txtContact)
If (IsNull(Me.txtContactPhone) = True) Then
strPhone = ""
Else
strPhone = Trim(Me.txtContactPhone)
End If
If (IsNull(Me.txtContactEmail) = True) Then
strEmail = ""
Else
strEmail = Trim(Me.txtContactEmail)
End If
If (IsNull(Me.txtFax) = True) Then
strFax = ""
Else
strFax = Trim(Me.txtFax)
End If
If (IsNull(Me.txtContactNotes) = True) Then
strNotes = ""
Else
strNotes = Trim(Me.txtContactNotes)
End If
Set db = CurrentDb
Set rstApp = db.OpenRecordset("tblContacts", dbOpenDynaset, dbSeeChanges)
With rstApp
..AddNew
!Contact = strContact
!Phone = strPhone
![E-mail] = strEmail ' Not showing value when hovering my mouse on ![E-mail]
!Fax = strFax
!Notes = strNotes
' ' DoCmd.GoToRecord , , acNewRec
..Update
MsgBox ("Record added to the system")
End With
Dim strDocName As String
strDocName = "frmActionRequestFiltered"
If IsLoaded(strDocName) Then
Forms(strDocName)!cboContacts.Requery
End If
strDocName = "frmActionRequest"
If IsLoaded(strDocName) Then
Forms(strDocName)!cboContacts.Requery
End If
Me.txtContact = ""
Me.txtContactPhone = ""
Me.txtContactEmail = ""
Me.txtFax = ""
Me.txtContactNotes = ""
End If
rstApp.Close
Set rstApp = Nothing
Set db = Nothing
Exit_btnAdd_Click:
Exit Sub
Err_btnAdd_Click:
MsgBox Err.Description
Resume Exit_btnAdd_Click