I get this error message :
Object variable or with block variable not set
on this :
Private Sub CmndAddTenant_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim TSSN As String
Dim TFN As String
Dim TDOB As Date
Dim msg As Integer
Dim TF As String
Dim TMS As String
Dim TNC As Double
Dim TBUID As String
Dim TOD As String
Dim SD1 As String
Dim SD2 As String
Dim SD3 As String
Dim FI As Image
Dim SI As Image
Dim TI As Image
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("TblTenants")
TSSN = Me.TenantSSN.Value
TFN = Me.TenantName.Value
TDOB = Me.TenantDOB.Value
TF = Me.TenantPhone.Value
TMS = Me.TenantMStatus.Value
TNC = Me.TenantNChildren.Value
TBUID = Me.BUID.Value
TOD = Me.TenantOcupationD.Value
SD1 = Me.SuportDoc1.Value
SD2 = Me.SuportDoc2.Value
SD3 = Me.SuportDoc3.Value
FI = Me.ImagFirstDocument.Value
SI = Me.ImagSecondDocument.Value
TI = Me.ImagThirdDocument.Value
With rst
.AddNew
!BUID = TBUID ' Add data.
!SSN = TSSN
!TenantStatus = TMS
!TenantChildren = TNC
!TenantDocumentInfo1 = SD1
!TenantDocumentInfoImage1 = FI
!TenantDocumentInfo2 = SD2
!TenantDocumentInfoImage2 = SI
!TenantDocumentInfo3 = SD3
!TenantDocumentInfoImage3 = TI
!OccupationDate = TOD
.Update
.Bookmark = .LastModified
End With
rst.Close
End Sub
Object variable or with block variable not set
on this :
Private Sub CmndAddTenant_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim TSSN As String
Dim TFN As String
Dim TDOB As Date
Dim msg As Integer
Dim TF As String
Dim TMS As String
Dim TNC As Double
Dim TBUID As String
Dim TOD As String
Dim SD1 As String
Dim SD2 As String
Dim SD3 As String
Dim FI As Image
Dim SI As Image
Dim TI As Image
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("TblTenants")
TSSN = Me.TenantSSN.Value
TFN = Me.TenantName.Value
TDOB = Me.TenantDOB.Value
TF = Me.TenantPhone.Value
TMS = Me.TenantMStatus.Value
TNC = Me.TenantNChildren.Value
TBUID = Me.BUID.Value
TOD = Me.TenantOcupationD.Value
SD1 = Me.SuportDoc1.Value
SD2 = Me.SuportDoc2.Value
SD3 = Me.SuportDoc3.Value
FI = Me.ImagFirstDocument.Value
SI = Me.ImagSecondDocument.Value
TI = Me.ImagThirdDocument.Value
With rst
.AddNew
!BUID = TBUID ' Add data.
!SSN = TSSN
!TenantStatus = TMS
!TenantChildren = TNC
!TenantDocumentInfo1 = SD1
!TenantDocumentInfoImage1 = FI
!TenantDocumentInfo2 = SD2
!TenantDocumentInfoImage2 = SI
!TenantDocumentInfo3 = SD3
!TenantDocumentInfoImage3 = TI
!OccupationDate = TOD
.Update
.Bookmark = .LastModified
End With
rst.Close
End Sub