J
Joe Cilinceon
First I'm having 2 problems with some code on a button. The code is listed
at the bottom of this message. The first problem is the if then else in the
code. If the combo is empty I want it to put up a message that you must have
selected a unit before you can transfer. I've tried several ways now and it
just by passes that part of the statement and does the else part. The second
problem is how to write an SQL query to Update a table for a single unit.
Any help would be greatly appreciated.
If Me![cboVacantUnits] = Null Then 'This line is not working
I've even tried but runs from the Else regardless without problem
MsgBox "You Must Pick A Unit First"
Else
' Update Tenant's Credit for Possible Refund
[Credits] = [Credits] + Me.Refund
'Rent the New Unit
Dim strSQL1 As String
strSQL1 = ""
**** Here I need an Update Query with no idea how to make it work since I've
never been able to do it even with the wizard ****
'Update Rented Units Form
[fsubRentedUnits].Form![CustNo] = Null
[fsubRentedUnits].Form![EndDate] = Date
[fsubRentedUnits].Form![LastRate] = [fsubRentedUnits].Form![Rate]
[fsubRentedUnits].Form![Rate] = Null
[fsubRentedUnits].Form![Status] = 2
[fsubRentedUnits].Form![LastStartDate] =
[fsubRentedUnits].Form![StartDate]
[fsubRentedUnits].Form![StartDate] = Null
' Add a Note to Tenant's file
Dim strSQL2 As String
strSQL2 = "INSERT INTO tblTenantNotes ( CustNo, NoteDate, [Note] )"
& _
"SELECT '" & [CustNo] & "', Date() AS NoteDate, " & _
"'TRANSFERRED:From Unit #" & fsubRentedUnits.Form!Unit & _
" to Unit #" & [cboVacantUnits] & "' AS [Note];"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL2
DoCmd.SetWarnings True
End If
End Sub
at the bottom of this message. The first problem is the if then else in the
code. If the combo is empty I want it to put up a message that you must have
selected a unit before you can transfer. I've tried several ways now and it
just by passes that part of the statement and does the else part. The second
problem is how to write an SQL query to Update a table for a single unit.
Any help would be greatly appreciated.
If Me![cboVacantUnits] = Null Then 'This line is not working
I've even tried but runs from the Else regardless without problem
MsgBox "You Must Pick A Unit First"
Else
' Update Tenant's Credit for Possible Refund
[Credits] = [Credits] + Me.Refund
'Rent the New Unit
Dim strSQL1 As String
strSQL1 = ""
**** Here I need an Update Query with no idea how to make it work since I've
never been able to do it even with the wizard ****
'Update Rented Units Form
[fsubRentedUnits].Form![CustNo] = Null
[fsubRentedUnits].Form![EndDate] = Date
[fsubRentedUnits].Form![LastRate] = [fsubRentedUnits].Form![Rate]
[fsubRentedUnits].Form![Rate] = Null
[fsubRentedUnits].Form![Status] = 2
[fsubRentedUnits].Form![LastStartDate] =
[fsubRentedUnits].Form![StartDate]
[fsubRentedUnits].Form![StartDate] = Null
' Add a Note to Tenant's file
Dim strSQL2 As String
strSQL2 = "INSERT INTO tblTenantNotes ( CustNo, NoteDate, [Note] )"
& _
"SELECT '" & [CustNo] & "', Date() AS NoteDate, " & _
"'TRANSFERRED:From Unit #" & fsubRentedUnits.Form!Unit & _
" to Unit #" & [cboVacantUnits] & "' AS [Note];"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL2
DoCmd.SetWarnings True
End If
End Sub