gold007eye
Registered User.
- Local time
- Today, 14:01
- Joined
- May 11, 2005
- Messages
- 260
I am in the process of converting my database backend from Access to SQL Server 2005. Everything was going pretty good until I hit a snag with this query. This worked fine until I moved the tables to SQL Server.
To give you an idea of what this query is supposed to do. I have a search form with 9 options for the user to search by. a Minimum of 1 search criteria is required. (See attached image taken from Access Backend version). A user can use as many or few criteria in an effort to narrow down the results.
I have tried to re-write the query to work with the SQL tables to no avail.. the best I can do is have 1 specific search criteria work, but not the others.
Could someone show me how I need to reformat this to work with the SQL tables? I keep getting OBDC Error (3146) when I try to run the query on the Front End.
Here is the code:
The OBDC error doesn't seem to appear until this point in the code:
Any help would be greatly appreciated so I can move forward with this project
To give you an idea of what this query is supposed to do. I have a search form with 9 options for the user to search by. a Minimum of 1 search criteria is required. (See attached image taken from Access Backend version). A user can use as many or few criteria in an effort to narrow down the results.
I have tried to re-write the query to work with the SQL tables to no avail.. the best I can do is have 1 specific search criteria work, but not the others.
Could someone show me how I need to reformat this to work with the SQL tables? I keep getting OBDC Error (3146) when I try to run the query on the Front End.
Here is the code:
Code:
SELECT [Letter Information].ID, [Letter Information].[Provider Name], [Letter Information].CCN, [Letter Information].PTAN, [Letter Information].[Letter Type], [Letter Information].[Letter Date], [Letter Information].[Contact Name], [Letter Information].Analyst, [Letter Information].[Address Line 1], [Letter Information].[Address Line 2], [Letter Information].City, [Letter Information].State, [Letter Information].[Zip Code]
FROM [Letter Information] INNER JOIN [Letter Names] ON [Letter Information].[Letter Type] = [Letter Names].[Letter Name]
WHERE ((([Analyst]=[Forms]![Search Form]![Analyst] Or [Forms]![Search Form]![Analyst] Is Null)=True) AND (([Letter Type]=[Forms]![Search Form]![Letter Type] Or [Forms]![Search Form]![Letter Type] Is Null)=True) AND (([Letter Date]=[Forms]![Search Form]![Letter Date] Or [Forms]![Search Form]![Letter Date] Is Null)=True) AND (([Provider Name] Like [Forms]![Search Form]![First Name] & "*" Or [Forms]![Search Form]![First Name] Is Null)=True) AND (([Provider Name] Like "*" & [Forms]![Search Form]![Last Name] Or [Forms]![Search Form]![Last Name] Is Null)=True) AND (([PTAN] Like [Forms]![Search Form]![PTAN] & "*" Or [Forms]![Search Form]![PTAN] Is Null)=True) AND (([CCN] Like [Forms]![Search Form]![CCN] & "*" Or [Forms]![Search Form]![CCN] Is Null)=True) AND (([Provider Name] Like "*" & [Forms]![Search Form]![Provider Name] & "*" Or [Forms]![Search Form]![Provider Name] Is Null)=True) AND (([Contact Name] Like "*" & [Forms]![Search Form]![Contact Name] & "*" Or [Forms]![Search Form]![Contact Name] Is Null)=True) AND (([Letter Names].Status)=True))
ORDER BY [Letter Information].[Provider Name], [Letter Information].[Letter Type], [Letter Information].[Letter Date];
The OBDC error doesn't seem to appear until this point in the code:
Code:
WHERE ((([Analyst]=[Forms]![Search Form]![Analyst] Or [Forms]![Search Form]![Analyst] Is Null)=True) AND (([Letter Type]=[Forms]![Search Form]![Letter Type] Or [Forms]![Search Form]![Letter Type] Is Null)=True) AND (([Letter Date]=[Forms]![Search Form]![Letter Date] Or [Forms]![Search Form]![Letter Date] Is Null)=True) AND (([Provider Name] Like [Forms]![Search Form]![First Name] & "*" Or [Forms]![Search Form]![First Name] Is Null)=True) AND (([Provider Name] Like "*" & [Forms]![Search Form]![Last Name] Or [Forms]![Search Form]![Last Name] Is Null)=True) AND (([PTAN] Like [Forms]![Search Form]![PTAN] & "*" Or [Forms]![Search Form]![PTAN] Is Null)=True) AND (([CCN] Like [Forms]![Search Form]![CCN] & "*" Or [Forms]![Search Form]![CCN] Is Null)=True) AND (([Provider Name] Like "*" & [Forms]![Search Form]![Provider Name] & "*" Or [Forms]![Search Form]![Provider Name] Is Null)=True) AND (([Contact Name] Like "*" & [Forms]![Search Form]![Contact Name] & "*" Or [Forms]![Search Form]![Contact Name] Is Null)=True) AND (([Letter Names].Status)=True))
ORDER BY [Letter Information].[Provider Name], [Letter Information].[Letter Type], [Letter Information].[Letter Date];
Any help would be greatly appreciated so I can move forward with this project
