Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 [RESOLVED]If field is null, use another.

Author  Topic 

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2009-10-19 : 05:53:22
Hi Experts,

I am porting some data over to a new database that I have made.

Now I have CustomerContacts and Customers. What I am trying to do is load contacts in. Now when im doing this I am getting the customerContacts number from the table. Sometimes however, the contacts don't have a number... if this is the case I am trying to use the companies number instead against that contact.

Eg;

INSERT INTO dbo_TBLCOMPANYCONTACTNUMBERS ( COMPANYCONTACTID, COMPANYCONTACTNUMBERTYPEID, COMPANYCONTACTNUMBER, ADDEDON, ADDEDBY )
SELECT dbo_TBLCOMPANYCONTACTS.COMPANYCONTACTID, 1 AS Expr1, Nz([Custcon].[phone],[Customer].[Phone]) AS Expr4, Date() AS Expr2, "Barry" AS Expr3
FROM (dbo_Custcon INNER JOIN (dbo_TBLCOMPANYCONTACTS RIGHT JOIN dbo_TBLCOMPANY ON dbo_TBLCOMPANYCONTACTS.COMPANYID = dbo_TBLCOMPANY.COMPANYID) ON dbo_Custcon.Code = dbo_TBLCOMPANY.COMPANYCODE) INNER JOIN dbo_Customer ON dbo_Custcon.Code = dbo_Customer.Code;


"Impossible is Nothing"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-10-19 : 06:28:31
Did you get any error?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2009-10-19 : 06:37:55
Thanks for your help Madhivanan, it was my alias's... dbo_ ;-) thanks again.

"Impossible is Nothing"
Go to Top of Page
   

- Advertisement -