Module to Update tables (skip blank fields) (1 Viewer)

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
 

Paul Buttress

Registered User.
Local time
Today, 19:38
Joined
Feb 4, 2008
Messages
25
Hi Tiffosi

Have you tried

If rstOutlook!Address = "" or isnull(rstOutlook!Address) Then

because the address itself could be set to NULL

Just a thought!
 

Tiffosi2007

Registered User.
Local time
Today, 19:38
Joined
Sep 13, 2007
Messages
50
Paul,

Thanks for the suggestion.

Worked a treat as far as i can see!
 

Tiffosi2007

Registered User.
Local time
Today, 19:38
Joined
Sep 13, 2007
Messages
50
Paul,

Thanks for the input. As far as i can see your suggestion worked perfectly.

Thanks again.

Kev
 

Users who are viewing this thread

Top Bottom