305 line Command Button Slow

M

Micah Chaney

I have a Command Button with 305 lines of code associated with it. Approx.
150 of the lines are Setting Objects, the rest are actual code. Granted I
have them spread out, so when concatenating fields, I can have that one
statement stretch out over several lines. My problem is, the button is
taking a minute+ to run. I can't seem to figure out why other than it's a
lot of code. Can someone help me? I've posted the code below. Any help is
appreciated.

Sub Save34_Click

'Sets Object Controls for Save34 Command Button On Click

Set objControl025 = Item.UserProperties("PONum")

Set objControl026 = Item.UserProperties("AcctRep")

Set objControl027 = Item.UserProperties("CustNum")

Set objControl028 = Item.UserProperties("CSR")

Set objControl029 = Item.UserProperties("DateRecd")

Set objControl030 = Item.UserProperties("OrderType")

Set objControl031 = Item.UserProperties("3rdPartyBilling")

Set objControl032 = Item.UserProperties("VolumeBuyer")

Set objControl033 = Item.UserProperties("ListRental")

Set objControl034 = Item.UserProperties("ExpDate")

Set objControl035 = Item.UserProperties("BizCode")

Set objControl036 = Item.UserProperties("CommStatus")

Set objControl037 = Item.UserProperties("ETA")

Set objControl038 = Item.UserProperties("MailDate")

Set objControl039 = Item.UserProperties("DateShpd")

Set objControl040 = Item.UserProperties("ShipVia")

Set objControl041 = Item.UserProperties("Dlvry1")

Set objControl042 = Item.UserProperties("Dlvry2")

Set objControl043 = Item.UserProperties("Dlvry3")

Set objControl044 = Item.UserProperties("Mailer")
Set objControl045 = Item.UserProperties("Broker")

Set objControl046 = Item.UserProperties("Name")

Set objControl047 = Item.UserProperties("Offer")

Set objControl048 = Item.UserProperties("PkgID")

Set objControl049 = Item.UserProperties("OrderOwner")

Set objControl050 = Item.UserProperties("PayStatus")

Set objControl051 = Item.UserProperties("RespDept")

Set objControl052 = Item.UserProperties("RerunReason")

Set objControl053 = Item.UserProperties("OrigOrderNum")

Set objControl054 = Item.UserProperties("SPA")

Set objControl055 = Item.UserProperties("UMailing")

Set objControl056 = Item.UserProperties("Uses")

Set objControl057 = Item.UserProperties("UPhoning")

Set objControl058 = Item.UserProperties("UFaxing")

Set objControl059 = Item.UserProperties("Uses2")

Set objControl060 = Item.UserProperties("BillingComments")

Set objControl061 = Item.UserProperties("CConFile")

Set objControl062 = Item.UserProperties("SKAInfo-Direct")

Set objControl063 = Item.UserProperties("AlvionRefNum")

Set objControl064 = Item.UserProperties("ReasonCode")

Set objControl065 = Item.UserProperties("SpecInstr")

Set objControl066 = Item.UserProperties("AttachmentsFlag")

Set objControl067 = Item.UserProperties("ForeignStates")

Set objControl068 = Item.UserProperties("Database1")

Set objControl069 = Item.UserProperties("DedupMng1")

Set objControl070 = Item.UserProperties("DeptCode1")

Set objControl071 = Item.UserProperties("Specialty1")

Set objControl072 = Item.UserProperties("Omit1")

Set objControl073 = Item.UserProperties("KeyCode1")

Set objControl074 = Item.UserProperties("QuoteCount1")

Set objControl075 = Item.UserProperties("ActualCount1")

Set objControl076 = Item.UserProperties("Nth1")

Set objControl077 = Item.UserProperties("Database2")

Set objControl078 = Item.UserProperties("DedupMng2")

Set objControl079 = Item.UserProperties("DeptCode2")

Set objControl080 = Item.UserProperties("Specialty2")

Set objControl081 = Item.UserProperties("Omit2")

Set objControl082 = Item.UserProperties("KeyCode2")

Set objControl083 = Item.UserProperties("QuoteCount2")

Set objControl084 = Item.UserProperties("ActualCount2")

Set objControl085 = Item.UserProperties("Nth2")

Set objControl086 = Item.UserProperties("Database3")

Set objControl087 = Item.UserProperties("DedupMng3")

Set objControl088 = Item.UserProperties("DeptCode3")

Set objControl089 = Item.UserProperties("Specialty3")

Set objControl090 = Item.UserProperties("Omit3")

Set objControl091 = Item.UserProperties("KeyCode3")

Set objControl092 = Item.UserProperties("QuoteCount3")

Set objControl093 = Item.UserProperties("ActualCount3")

Set objControl094 = Item.UserProperties("Nth3")

Set objControl095 = Item.UserProperties("Database4")

Set objControl096 = Item.UserProperties("DedupMng4")

Set objControl097 = Item.UserProperties("DeptCode4")

Set objControl098 = Item.UserProperties("Specialty4")

Set objControl099 = Item.UserProperties("Omit4")

Set objControl100 = Item.UserProperties("KeyCode4")

Set objControl101 = Item.UserProperties("QuoteCount4")

Set objControl102 = Item.UserProperties("ActualCount4")

Set objControl103 = Item.UserProperties("Nth4")

Set objControl104 = Item.UserProperties("Database5")

Set objControl105 = Item.UserProperties("DedupMng5")

Set objControl106 = Item.UserProperties("DeptCode5")

Set objControl107 = Item.UserProperties("Specialty5")

Set objControl108 = Item.UserProperties("Omit5")

Set objControl109 = Item.UserProperties("KeyCode5")

Set objControl110 = Item.UserProperties("QuoteCount5")

Set objControl111 = Item.UserProperties("ActualCount5")

Set objControl112 = Item.UserProperties("Nth5")

Set objControl113 = Item.UserProperties("Output")

Set objControl114 = Item.UserProperties("FileFormat")

Set objControl115 = Item.UserProperties("SpecsA")

Set objControl116 = Item.UserProperties("SpecsB")

Set objControl117 = Item.UserProperties("SpecsC")

Set objControl118 = Item.UserProperties("StartDate")

Set objControl119 = Item.UserProperties("ExpireDate")

Set objControl120 = Item.UserProperties("Updt1")

Set objControl121 = Item.UserProperties("Updt2")

Set objControl122 = Item.UserProperties("Updt3")

Set objControl123 = Item.UserProperties("Updt4")

Set objControl124 = Item.UserProperties("Updt5")

Set objControl125 = Item.UserProperties("RenewalDate")

Set objControl126 = Item.UserProperties("OptFldKeyCode")

Set objControl127 = Item.UserProperties("OptFldSize")

Set objControl128 = Item.UserProperties("OptFldSpecialty")

Set objControl129 = Item.UserProperties("OptFldDPB")

Set objControl130 = Item.UserProperties("OptFldSurgi")

Set objControl131 = Item.UserProperties("OptFldFS")

Set objControl132 = Item.UserProperties("OptFldChange")

Set objControl133 = Item.UserProperties("OptFldPhone")

Set objControl134 = Item.UserProperties("OptFldFax")

Set objControl135 = Item.UserProperties("OptFldAddress2")

Set objControl136 = Item.UserProperties("OptFldCity2")

Set objControl137 = Item.UserProperties("OptFldState2")

Set objControl138 = Item.UserProperties("OptFldZip2")

Set objControl139 = Item.UserProperties("OptFldFIPS")

Set objControl140 = Item.UserProperties("OptFldCode2")

Set objControl141 = Item.UserProperties("OptFldCode3")

Set objControl142 = Item.UserProperties("OptFldCode4")

Set objControl143 = Item.UserProperties("OptFldCode5")

Set objControl144 = Item.UserProperties("OptFldCode6")

Set objControl145 = Item.UserProperties("OptFldCode7")

Set objControl146 = Item.UserProperties("OptFldCode9")

Set objControl147 = Item.UserProperties("OptFldOrigDate")

Set objControl148 = Item.UserProperties("OptFldWebsite")

Set objControl149 = Item.UserProperties("OptFldLicNum")

Set objControl150 = Item.UserProperties("OptFldLicState")

Set objControl151 = Item.UserProperties("OptFldRegNo")

Set objControl152 = Item.UserProperties("OptFldUpIn")

Set objControl153 = Item.UserProperties("OptFldID")

Set objControl154 = Item.UserProperties("OptFldPersID")

Set objControl155 = Item.UserProperties("OptFldAHAID")

Set objControl156 = Item.UserProperties("OptFldHealthCare")

Set objControl157 = Item.UserProperties("OptFldRetail")

Set objControl158 = Item.UserProperties("OptFldHour24")

Set objControl159 = Item.UserProperties("OptFldDeaRegNo")

Set objControl160 = Item.UserProperties("OptFldNABP")

Set objControl161 = Item.UserProperties("OptFldOther")

Set objControl162 = Item.UserProperties("IncludeOther")

Set objControl163 = Item.UserProperties("QuoteCountTotal")

Set objControl164 = Item.UserProperties("ActualCountTotal")

Set objControl165 = Item.UserProperties("OrderStatus")

Set objControl166 = Item.UserProperties("CSMgrApproval")

Set objControl167 = Item.UserProperties("CSMgrApprovalDate")

Set objControl168 = Item.UserProperties("CreditApproval")

Set objControl169 = Item.UserProperties("CreditApprovalDate")

Set objControl170 = Item.UserProperties("OrderSizeApproval")

Set objControl171 = Item.UserProperties("OrderSizeApprovalDate")

Set objControl172 = Item.UserProperties("ContractApproval")

Set objControl173 = Item.UserProperties("ContractApprovalDate")

Set objControl174 = Item.UserProperties("QCApproval")

Set objControl175 = Item.UserProperties("QCApprovalDate")

Set objControl176 = Item.UserProperties("OrderSize")

'Combines all Custom Fields into Access "linkable" fields

Item.UserProperties("Assistant's Name").Value = objControl104 & "|a" & _

objControl105 & "|b" & _

objControl108 & "|c" & _

objControl109 & "|d" & _

objControl110 & "|e" & _

objControl111 & "|f" & _

objControl112

Item.UserProperties("Home Address").Value = objControl095 & "|a" & _

objControl096 & "|b" & _

objControl099 & "|c" & _

objControl100 & "|d" & _

objControl101 & "|e" & _

objControl102 & "|f" & _

objControl103

Item.UserProperties("Office Location").Value = objControl086 & "|a" & _

objControl087 & "|b" & _

objControl090 & "|c" & _

objControl091 & "|d" & _

objControl092 & "|e" & _

objControl093 & "|f" & _

objControl094

Item.UserProperties("Account").Value = objControl077 & "|a" & _

objControl078 & "|b" & _

objControl081 & "|c" & _

objControl082 & "|d" & _

objControl083 & "|e" & _

objControl084 & "|f" & _

objControl085

Item.UserProperties("Other Address").Value = objControl068 & "|a" & _

objControl069 & "|b" & _

objControl072 & "|c" & _

objControl073 & "|d" & _

objControl074 & "|e" & _

objControl075 & "|f" & _

objControl076

Item.UserProperties("Assistant's Phone").Value = objControl107

Item.UserProperties("Business Fax").Value = objControl098

Item.UserProperties("Home Fax").Value = objControl089

Item.UserProperties("Home Phone 2").Value = objControl080

Item.UserProperties("Mobile Phone").Value = objControl071

Item.UserProperties("Other Fax").Value = objControl106

Item.UserProperties("Pager").Value = objControl097

Item.UserProperties("Primary Phone").Value = objControl088

Item.UserProperties("Business Phone").Value = objControl079

Item.UserProperties("Telex").Value = objControl070

Item.UserProperties("Company").Value = objControl044 & "|a" & _

objControl045 & "|b" & _

objControl046 & "|c" & _

objControl047 & "|d" & _

objControl048

Item.UserProperties("First Name").Value = objControl025 & "|a" & _

objControl026 & "|b" & _

objControl028 & "|c" & _

objControl030 & "|d" & _

objControl031 & objControl032 & "|e" & _

objControl033 & "|f" & _

objControl036

Item.UserProperties("Last Name").Value = objControl027 & "|a" & _

objControl035 & "|b" & _

objControl040 & "|c" & _

objControl041 & "|d" & _

objControl042 & "|e" & _

objControl043 & "|f" & _

objControl113 & "|g" & _

objControl114 & "|h" & _

objControl116 & "|i" & _

objControl115 & "|j" & _

objControl117

Item.UserProperties("Title").Value = objControl166 & "|a" & _

objControl167 & "|b" & _

objControl168 & "|c" & _

objControl169 & "|d" & _

objControl170 & "|e" & _

objControl171 & "|f" & _

objControl172 & "|g" & _

objControl173 & "|h" & _

objControl174 & "|i" & _

objControl175 & "|j" & _

objControl176

Item.UserProperties("User Field 1").Value = objControl118 & "|a" & _

objControl119 & "|b" & _

objControl120 & "|c" & _

objControl121 & "|d" & _

objControl122 & "|e" & _

objControl123 & "|f" & _

objControl124 & "|g" & _

objControl125 & "|h" & _

objControl029 & "|i" & _

objControl034 & "|j" & _

objControl037 & "|k" & _

objControl038 & "|l" & _

objControl039

Item.UserProperties("User Field 2").Value = objControl165 & "|a" & _

objControl163 & "|b" & _

objControl164 & "|c" & _

objControl061 & "|d" & _

objControl055 & "|e" & _

objControl056 & "|f" & _

objControl057 & "|g" & _

objControl058 & "|h" & _

objControl059 & "|i" & _

objControl054 & "|j" & _

objControl050

Item.UserProperties("User Field 3").Value = objControl065 & "|a" & _

objControl066 & "|b" & _

objControl067 & "|c" & _

objControl062 & "|d" & _

objControl063 & objControl064

Item.UserProperties("User Field 4").Value = objControl060 & "|a" & _

objControl051 & "|b" & _

objControl052 & "|c" & _

objControl053

Item.UserProperties("Department").Value = objControl126 & "|a" & _

objControl127 & "|b" & _

objControl128 & "|c" & _

objControl129 & "|d" & _

objControl130 & "|e" & _

objControl131 & "|f" & _

objControl132 & "|g" & _

objControl133 & "|h" & _

objControl134 & "|i" & _

objControl135 & "|j" & _

objControl136 & "|k" & _

objControl137 & "|l" & _

objControl138 & "|m" & _

objControl139 & "|n" & _

objControl140 & "|o" & _

objControl141 & "|p" & _

objControl142 & "|q" & _

objControl143 & "|r" & _

objControl144 & "|s" & _

objControl145 & "|t" & _

objControl146 & "|u" & _

objControl147 & "|v" & _

objControl148 & "|w" & _

objControl149 & "|x" & _

objControl150 & "|y" & _

objControl151 & "|z" & _

objControl152 & "%a" & _

objControl153 & "%b" & _

objControl154 & "%c" & _

objControl155 & "%d" & _

objControl156 & "%e" & _

objControl157 & "%f" & _

objControl158 & "%g" & _

objControl159 & "%h" & _

objControl160 & "%i" & _

objControl161 & "%j" & _

objControl162

MsgBox "Done"

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top