Tiffosi2007
Registered User.
- Local time
- Today, 19:38
- Joined
- Sep 13, 2007
- Messages
- 50
Morning everyone,
Quickie for you, i have written code to loop through outlook contacts and add them to the DB if they are not already there. If they are, the code will switch to update mode.
I need to alter the code to tell it to skip part of a record if a field is blank (the address field). The update segement i have written like this. Everything works fine apart from this new bit of code which i have highlighted.
Basically i want to update the company and dept fields but then prior to updating the address, check if the field is blank. If it is, i want to skip the rest of the update and move the the next record. If it isnt i want to continue.
Can someone please point out my obvious mistake? It is ignoring the new if then else statement and updating every field in every record.
Thanks
rstOrg.Edit
rstOrg!Organisation = rstOutlook!Company & " " & rstOutlook!Department
rstOrg!Company = rstOutlook!Company
rstOrg!Department = rstOutlook!Department
If rstOutlook!Address = "" Then (i assume this would ignore the else and go straight to end if?)
Else
rstOrg!Building = rstOutlook!Address
rstOrg!Street = rstOutlook!City
rstOrg!City = rstOutlook!State
rstOrg!PostCode = rstOutlook![Zip/Postal Code]
rstOrg!OfficePhone = rstOutlook!Phone
rstOrg!OfficeFax = rstOutlook![Business Fax]
End If
rstOrg.Update
Quickie for you, i have written code to loop through outlook contacts and add them to the DB if they are not already there. If they are, the code will switch to update mode.
I need to alter the code to tell it to skip part of a record if a field is blank (the address field). The update segement i have written like this. Everything works fine apart from this new bit of code which i have highlighted.
Basically i want to update the company and dept fields but then prior to updating the address, check if the field is blank. If it is, i want to skip the rest of the update and move the the next record. If it isnt i want to continue.
Can someone please point out my obvious mistake? It is ignoring the new if then else statement and updating every field in every record.
Thanks
rstOrg.Edit
rstOrg!Organisation = rstOutlook!Company & " " & rstOutlook!Department
rstOrg!Company = rstOutlook!Company
rstOrg!Department = rstOutlook!Department
If rstOutlook!Address = "" Then (i assume this would ignore the else and go straight to end if?)
Else
rstOrg!Building = rstOutlook!Address
rstOrg!Street = rstOutlook!City
rstOrg!City = rstOutlook!State
rstOrg!PostCode = rstOutlook![Zip/Postal Code]
rstOrg!OfficePhone = rstOutlook!Phone
rstOrg!OfficeFax = rstOutlook![Business Fax]
End If
rstOrg.Update