Valery
Registered User.
- Local time
- Today, 11:51
- Joined
- Jun 22, 2013
- Messages
- 363
Hi all,
I have some coding that needs updating. I did not write the code and cannot perform the two updates required.
1) At the time the code was written the control text box name was status, same as the field name. I would like to change the control text box name to cboStatus for consistency. I don't know where in the code the name referred to represents the control name vs the field name.
2) The coding looks to ensure that before the form is closed, there must be one (and only one) tenant with a Status "F". The problem here is that the form is closed with a command button that opens another form (a listing). Currently, the code does not let you close the form (which is fine) but it does open the listing... It should prevent any other form from opening and remain on the screen.
If you need any other information, please let me know.
CODE:
I have some coding that needs updating. I did not write the code and cannot perform the two updates required.
1) At the time the code was written the control text box name was status, same as the field name. I would like to change the control text box name to cboStatus for consistency. I don't know where in the code the name referred to represents the control name vs the field name.
2) The coding looks to ensure that before the form is closed, there must be one (and only one) tenant with a Status "F". The problem here is that the form is closed with a command button that opens another form (a listing). Currently, the code does not let you close the form (which is fine) but it does open the listing... It should prevent any other form from opening and remain on the screen.
If you need any other information, please let me know.
CODE:
Code:
Public Function chkStatus() As Boolean
Dim rs As DAO.Recordset
Dim iCount As Integer
Set rs = Me.RecordsetClone
'Me.Parent.pStatus = True
With rs
If Not (.BOF And .EOF) Then
.MoveFirst
.FindFirst "[Status] = " & Chr(34) & "F" & Chr(34) & _
" And [UnitNum] = " & Me.Parent![UnitNum]
If .NoMatch Then
MsgBox "You must designate at least one Main Tenant (status F).", _
vbInformation + vbOKOnly, _
"Tenant Status"
chkStatus = True
End If
End If
.Close
End With
Set rs = Nothing
End Function
Private Sub Status_BeforeUpdate(Cancel As Integer)
Dim rs As DAO.Recordset
If Me.Status = "F" Then
Set rs = Me.RecordsetClone
With rs
If Not (.BOF And .EOF) Then
.FindFirst "[Status] = " & Chr(34) & Me.Status & Chr(34) & _
" And [UnitNum] = " & Me.Parent![UnitNum]
If Not .NoMatch Then
If ![TenantID] <> Nz(Me.TenantID, 0) Then
MsgBox "You already selected a Main Tenant", _
vbInformation + vbOKOnly, _
"Tenant Status"
Me.Status.Undo
Cancel = True
End If
End If
End If
.Close
End With
Set rs = Nothing
End If
End Sub