graviz
Registered User.
- Local time
- Today, 10:02
- Joined
- Aug 4, 2009
- Messages
- 167
I'm attemping to update a record in a table "Com_MDU_Table" using a form with a bunch of txt and combo boxes. The record is based upon the Property Name. I have it set as the primary key in my table so it does not create duplicate records of the same property. I've attached the error I'm getting when I try and change one of the other fields and click on the update button (code is below).
Private Sub CMD_Update_Click()
Dim CDB As Object
Dim RS_CPT As Object
Dim PropertyName As String
Dim ActivityStatus As String
Dim RTM As String
Dim Address As String
Dim City As String
Dim State As String
Dim Zip As String
Dim ASM As String
Dim PropType As String
Dim NewExisting As String
Dim NumOfUnits As String
Dim NumOfBuildings As String
Dim NumOfFloors As String
Dim SystemType As String
Dim HSD As String
Dim UserName As String
UserName = fOSUserName
PropertyName = Forms!frm_update_prop!TXT_Prop_Name.Value
ActivityStatus = Forms!frm_update_prop!TXT_Act_Status.Value
RTM = Forms!frm_update_prop!TXT_RTM.Value
Address = Forms!frm_update_prop!TXT_Address.Value
City = Forms!frm_update_prop!TXT_City.Value
State = Forms!frm_update_prop!TXT_State.Value
Zip = Nz(Forms!frm_update_prop!TXT_Zip.Value)
ASM = Forms!frm_update_prop!TXT_ASM.Value
PropType = Forms!frm_update_prop!TXT_Prop_Type.Value
NewExisting = Forms!frm_update_prop!TXT_New_Exist.Value
NumOfUnits = Forms!frm_update_prop!TXT_Num_Units.Value
NumOfBuildings = Forms!frm_update_prop!TXT_Num_Build.Value
NumOfFloors = Forms!frm_update_prop!TXT_Num_Floors.Value
SystemType = Forms!frm_update_prop!TXT_Sys_Type.Value
HSD = Forms!frm_update_prop!TXT_HSD.Value
Set CDB = CurrentDb
Set RS_CPT = CDB.OpenRecordset("Com_MDU_Table")
RS_CPT.Edit
RS_CPT("Property_Name").Value = PropertyName
RS_CPT("Account_Status").Value = ActivityStatus
RS_CPT("RTM").Value = RTM
RS_CPT("Address").Value = Address
RS_CPT("City").Value = City
RS_CPT("State").Value = State
RS_CPT("Zip").Value = Zip
RS_CPT("ASM").Value = ASM
RS_CPT("Property_Type").Value = PropType
RS_CPT("New_Existing").Value = NewExisting
RS_CPT("Num_of_Units").Value = NumOfUnits
RS_CPT("Num_of_Buildings").Value = NumOfBuildings
RS_CPT("Num_of_Floors").Value = NumOfFloors
RS_CPT("System_Type").Value = SystemType
RS_CPT("HSD").Value = HSD
RS_CPT("NT_Login").Value = UserName
RS_CPT.Update
Set RS_CPT = Nothing
Set CDB = Nothing
MsgBox "The property" & " " & PropertyName & " " & "has been updated", vbOKOnly, "Record Updated"
End Sub
Private Sub CMD_Update_Click()
Dim CDB As Object
Dim RS_CPT As Object
Dim PropertyName As String
Dim ActivityStatus As String
Dim RTM As String
Dim Address As String
Dim City As String
Dim State As String
Dim Zip As String
Dim ASM As String
Dim PropType As String
Dim NewExisting As String
Dim NumOfUnits As String
Dim NumOfBuildings As String
Dim NumOfFloors As String
Dim SystemType As String
Dim HSD As String
Dim UserName As String
UserName = fOSUserName
PropertyName = Forms!frm_update_prop!TXT_Prop_Name.Value
ActivityStatus = Forms!frm_update_prop!TXT_Act_Status.Value
RTM = Forms!frm_update_prop!TXT_RTM.Value
Address = Forms!frm_update_prop!TXT_Address.Value
City = Forms!frm_update_prop!TXT_City.Value
State = Forms!frm_update_prop!TXT_State.Value
Zip = Nz(Forms!frm_update_prop!TXT_Zip.Value)
ASM = Forms!frm_update_prop!TXT_ASM.Value
PropType = Forms!frm_update_prop!TXT_Prop_Type.Value
NewExisting = Forms!frm_update_prop!TXT_New_Exist.Value
NumOfUnits = Forms!frm_update_prop!TXT_Num_Units.Value
NumOfBuildings = Forms!frm_update_prop!TXT_Num_Build.Value
NumOfFloors = Forms!frm_update_prop!TXT_Num_Floors.Value
SystemType = Forms!frm_update_prop!TXT_Sys_Type.Value
HSD = Forms!frm_update_prop!TXT_HSD.Value
Set CDB = CurrentDb
Set RS_CPT = CDB.OpenRecordset("Com_MDU_Table")
RS_CPT.Edit
RS_CPT("Property_Name").Value = PropertyName
RS_CPT("Account_Status").Value = ActivityStatus
RS_CPT("RTM").Value = RTM
RS_CPT("Address").Value = Address
RS_CPT("City").Value = City
RS_CPT("State").Value = State
RS_CPT("Zip").Value = Zip
RS_CPT("ASM").Value = ASM
RS_CPT("Property_Type").Value = PropType
RS_CPT("New_Existing").Value = NewExisting
RS_CPT("Num_of_Units").Value = NumOfUnits
RS_CPT("Num_of_Buildings").Value = NumOfBuildings
RS_CPT("Num_of_Floors").Value = NumOfFloors
RS_CPT("System_Type").Value = SystemType
RS_CPT("HSD").Value = HSD
RS_CPT("NT_Login").Value = UserName
RS_CPT.Update
Set RS_CPT = Nothing
Set CDB = Nothing
MsgBox "The property" & " " & PropertyName & " " & "has been updated", vbOKOnly, "Record Updated"
End Sub