Trying To Convert SQL Query To Access, Don't Know Where To Start

Jul 12, 2005

I just started working for a company the other week and they threw this query onto my lap with an unrealistic deadline. My programming experience is primarily in VB6, so I am not completely familiar with coding Access queries.

I was given code that was written for SQL, and the programmer that came up with it is unfamiliar with Access, so I am stuck trying to decipher this. If anyone could help me out, I would greatly appreciate it, as I am thoroughly confused and don't know where to begin. Here is the programmer's original code:
while exists(select top 1 accNum from NoteFile where patindex('%' + char(10) + '%',dbtrref) > 0)
begin
--Insert note into table
insert into #TL19Note(AcctNumber, Note)
select accNum, (case when patindex('%' + char(10) + '%',
dbtrref) <= 0 then dbtrref else left(dbtrref,patindex('%' + char(10) +
'%',dbtrref)) end)
from NoteFile

--Delete note from Note String
update NoteFile
set dbtrref = right(dbtrref,len(dbtrref)-len(left(dbtrref,patindex('%' + char(10) + '%',dbtrref))))
where len(dbtrref)-len(left(dbtrref,patindex('%' + char(10) +'%',dbtrref))) > 0

--Delete rows with no more notes
delete from NoteFile
where len(dbtrref)-len(left(dbtrref,patindex('%' + char(10) +'%',dbtrref))) <= 0 or patindex('%' +char(10) + '%',dbtrref) <= 0
end

--Eliminates any that are CRLR or just spaces
delete from #TL19Note
where len(Note) < 10

--Update the date
update #TL19Note
set NoteDate =left(Note,patindex('% %',Note)-1),
Note = right(Note,len(Note)-patindex('% %',Note))

--No '@' means no time?
update #TL19Note
set NoteTime = '0000'
where left(Note,1) <> '@'

--delete the '@' - we know which ones have it because NoteTime is null
update #TL19Note
set Note = right(Note,len(Note)-patindex('% %',Note))
where left(Note,1) = '@'

--Update NoteTime, take time out of note
update #TL19Note
set NoteTime = left(Note,2) + substring(note,4,2),
Note = right(Note,len(Note)-patindex('% %',Note))

View Replies


ADVERTISEMENT

Convert And Sql Query To Access

Sep 15, 2007

someone wrote this query for me in SQL and there is one part of it I don't understand can someone tell me how to convert this line for access? I don't know what || is

TO_NUMBER(SUBSTR(TO_CHAR(WE.mth_welfare),5,2) ||
SUBSTR(TO_CHAR(WE.mth_welfare),1,4)) an_mth_welfare


SELECT
WE.mth_welfare,
WE.id_case_welfare,
WE.id_case,
OB.id_member,
SUM(WE.amt_mtd_assist_expnd),
SUM(WE.amt_ltd_assist_expnd),
SUM(WE.amt_ltd_assist_recoup),
TO_NUMBER(SUBSTR(TO_CHAR(WE.mth_welfare),5,2) ||
SUBSTR(TO_CHAR(WE.mth_welfare),1,4)) an_mth_welfare
FROM noldba.welfare_balance_by_obligation WE, noldba.obligation OB
WHERE WE.id_case = OB.id_case
AND WE.seq_order = OB.seq_order
AND WE.seq_obligation = OB.seq_obligation

AND WE.mth_welfare <= 200708
AND WE.dt_END_validity = '31-DEC-9999'
AND WE.dt_end_validity = OB.dt_end_validity
AND OB.dt_beg_obligation = (SELECT MAX(c.dt_beg_obligation)
FROM noldba.obligation c
WHERE c.id_case = ob.id_Case
AND c.seq_order = ob.seq_order
AND c.seq_obligation = ob.seq_obligation
AND c.dt_end_validity = '31-DEC-9999')
GROUP BY WE.id_Case, OB.id_member, WE.id_case_welfare, WE.mth_welfare
ORDER BY WE.mth_welfare DESC,
WE.id_case DESC,
OB.id_member DESC;

View 3 Replies View Related

Convert SQL Query To Access

Dec 18, 2007

I have this query which I use with a program called "Query Reporter" - it runs well and gives me the correct answers.
Select COUNT (b.case_id),
sum(a.amt_to_distribute) Held_amt,
iv_d_do_code,
cd_reason_status--HELD REASONS-DH-DIST,NX-NO OBL,XS-EXCESS OBL,MW-MANU WKR,HM-NO MHIS,CC-CLOSED
From vrcth a, vcase b
Where A.Cd_Status_Receipt = 'H'
And A.Dt_Distribute = '01-JAN-0001'
And A.Dt_End_Validity = '31-DEC-9999'
AND Not Exists (Select 1 from vrcth k -- Checking receipt is not backed out
where a.dt_batch = k.dt_batch
ANd a.no_batch = k.no_batch
And a.cd_source_batch = k.cd_source_batch
And a.seq_receipt = k.seq_receipt
And k.ind_backout = 'Y'
And k.dt_end_validity = '31-DEC-9999')
And ((trim(A.Id_Case) IS NOT NULL -- When receipt is case identified
AND A.Id_case = b.case_id )
Or
( trim(A.Id_Case) IS NULL -- When receipt is payor identified
ANd b.case_id = (Select Min(y.case_id) from vcase Y, vcmem Z
Where A.Id_Payor = z.member_id
And z.relation_code IN ('A','P')
And z.case_id = y.case_id )
))
group by iv_d_do_code,
cd_reason_status
order by iv_d_do_code;

What I want to do is to rewrite the query in Access and get the same results. This is what I came up with which is returning nothing. Would someone please give the two of them a look and tell me what I'm missing the in Access query. Thanks

SELECT Count(b.CASE_ID) AS CountOfCASE_ID, Sum(a.AMT_TO_DISTRIBUTE) AS Held_amt, b.IV_D_DO_CODE, a.CD_REASON_STATUS
FROM NOLDBA_RECEIPT AS a, NOLDBA_INT_CASE_STATUS AS b
WHERE (((Trim([a].[id_case])) Is Not Null) AND ((a.ID_CASE)=[b].[case_id]) AND ((a.CD_STATUS_RECEIPT)='H') AND ((a.DT_DISTRIBUTE)=#1/1/2001#) AND ((a.DT_END_VALIDITY)=#12/31/9999#) AND ((Exists (select 1 from NOLDBA_RECEIPT k
where a.dt_batch=k.dt_batch
and a.no_batch=k.no_batch
and a.cd_source_batch=k.cd_source_batch
and a.seq_receipt=k.seq_receipt
and k.ind_backout ='Y'
and k.dt_end_validity =#12/31/9999#))=False)) OR (((Trim([a].[id_case])) Is Null) AND ((a.CD_STATUS_RECEIPT)='H') AND ((a.DT_DISTRIBUTE)=#1/1/2001#) AND ((a.DT_END_VALIDITY)=#12/31/9999#) AND ((Exists (select 1 from NOLDBA_RECEIPT k
where a.dt_batch=k.dt_batch
and a.no_batch=k.no_batch
and a.cd_source_batch=k.cd_source_batch
and a.seq_receipt=k.seq_receipt
and k.ind_backout ='Y'
and k.dt_end_validity =#12/31/9999#))=False) AND ((b.CASE_ID)=(select min (y.case_id) from NOLDBA_INT_CASE_STATUS Y, NOLDBA_INT_CASE_MEMBER Z
WHERE A.ID_PAYOR=Z.MEMBER_ID
AND Z.RELATION_CODE IN ('A','P')
AND Z.CASE_ID=Y.CASE_ID)))
GROUP BY b.IV_D_DO_CODE, a.CD_REASON_STATUS
ORDER BY b.IV_D_DO_CODE;

View 3 Replies View Related

Convert From Access Query To MS SQL View

Oct 21, 2005

Hi folks,

I have a query which pulls together several other queries. It works fine in Access but I also need it to work on a MS SQL server.

the SQL is as follows;

SELECT Client.ClientName, Entity.EntityName, IIf([101].[ProductID] IS NULL, [-], [X]) AS TA, IIf([301].[ProductID] IS NULL, [-], [X]) AS TR, IIf([302].[ProductID] IS NULL,
[-], [X]) AS CU, IIf([304].[ProductID] IS NULL, [-], [X]) AS TC, IIf([502].[ProductID] IS NULL, [-], [X]) AS FA, IIf([503].[ProductID] IS NULL, [-], [X]) AS MO
FROM Client LEFT JOIN
Entity ON Client.ClientID = Entity.ClientID LEFT JOIN
VIEW_PROD301 AS 301 ON Entity.EntityID = [301].EntityID LEFT JOIN
VIEW_PROD302 AS 302 ON Entity.EntityID = [302].EntityID LEFT JOIN
VIEW_PROD304 AS 304 ON Entity.EntityID = [304].EntityID LEFT JOIN
VIEW_PROD502 AS 502 ON Entity.EntityID = [502].EntityID LEFT JOIN
VIEW_PROD503 AS 503 ON Entity.EntityID = [503].EntityID LEFT JOIN
VIEW_PROD101 AS 101 ON Entity.EntityID = [101].EntityID;

The problem seems to be with the iif statement.

Any ideas how I can gt around this?

Thanks,

Dave

View 3 Replies View Related

Help CONVERT Access PIVOT QUERY To SQL SERVER

Oct 22, 2007

Can anyone help me convert this pivot query to work in sql server please?
I'll love you forever if you help me please :pTRANSFORM Count(Employees.MaritalStatus) AS MaritalStatusCount
SELECT Employees.MaritalStatus
FROM Employees INNER JOIN Offices ON Employees.OfficeId = Offices.officeId
WHERE ((Not (Employees.MaritalStatus) Is Null))
GROUP BY Employees.MaritalStatus
PIVOT Offices.officeLocation;

View 2 Replies View Related

How To Convert Number Date To Text In Access Query

Feb 12, 2015

how to convert number date to text date.

Ex. Date field: 02/12/2015

convert into:

Month field
February

Day Field
12

Year
2015

View 3 Replies View Related

Queries :: Convert String Back To Hyperlink In Access Query From SQL Table?

Nov 10, 2014

I am in the process of building a new database in SQL to replace my MS Access database. However, I will continue to use the Access forms, queries, and reports. The new tables will house much of the same data. In multiple tables I have hyperlinks that were created and added in the original Access tables. To import these hyperlinks into the new SQL tables I have converted them to 'Long Text' before exporting, thus changing them into strings.

For example:

Hyperlink - Email - Add Additional Mailbox to Outlook (2010) has been changed to:

Email - Add Additional Mailbox to Outlook (2010)#ServernameServerfolderDocumentationRea dy to GoOutlook TemplatesEmail - Add Additional Mailbox to Outlook (2010).oft#

The obvious issue that I am running into is that after the SQL database table has been linked to the Access database it still displays the entire string when I open the table. The form has a textbox and search button that is used as a search function. This runs a query that returns all "search results" for the desired information. Is there a way that the query can convert the string back into a hyperlink so that the query displays just Email - Add Additional Mailbox to Outlook (2010) as a hyperlink and not the entire string?

View 1 Replies View Related

I Have A Sql Query Pls Convert It To Ms Access Query

Mar 12, 2007

I have made this query in ms sql it works fine as per my needs iam getting the values but this doesn work in ms access 2002 can someone work this out its lil urgent tested out a lot of things but better to give the best people's n get their knowledge...

SELECT wc.windowsname FROM windowsconductivity as wc join constructiondetailes as cd on wc.windowsid=cd.materialid join uvalueconstruction as uc on uc.constructionid=cd.constructionid join projectmasterwindows as pmw on pmw.windowconstruction=uc.constructionname WHERE pmw.projectname='new8thmarch07' and pmw.windowconstruction='new8thmarch' and uc.constructiontype='windows' order by cd.constructiondetailsid

thanks aton...

View 7 Replies View Related

I Can't Start Access. Please Help.

Jun 11, 2007

This may sound a bit silly, but my Access 2003 refuses to start.

I recently re-installed Office 2003 after a fresh installation of WinXP. Word, Excel etc work as normal. This is the message that comes up when I attempt to start Access:

"Please wait while Office 2003 Prof. Ed. configures. Required data is being determined"

after that nothing happens.
Any ideas?

Please note that I'm using the German versions of OS and Office. My translation probably doesn't match the original message.

Thanks in advance.

View 2 Replies View Related

Microsoft Access Can't Start Because There Is No License For It On This Machine

Feb 1, 2005

I recently bought a new computer and it was kinda cheap, so no office products were installed on the computer. A friend loaned me her copy of Office 2003 which didn't have Access on it. So, after installing Office 2003 I picked my old Office 97 CD and installed just Access 97. Then I go to open the database and get this annoying message.

Microsoft Access can't start because there is no license for it on this machine.

Can anyone help? Thanks for your time.

View 1 Replies View Related

Start Up MS Access From Vb And Bypass Startup Macro

Jun 14, 2012

I know that I can startup MS-Access manually and bypass the startup options, including any macro that is set to run automatically, by holding the Shift key down when launching the application. I have:

Code:
Public Sub AccessStuff()
Dim myaccess As New Access.Application
myaccess.OpenCurrentDatabase(" orfs006slsops_repts\_RS DevSOPSOP.MDB")
Dim db = myaccess.CurrentDb()
End Sub

which works nicely and opens the database just fine. However, this mdb has a startup macro defined in it. I can't hold down the Shift key since I'm doing this from a program. In this case, how can I bypass the startup macro?

View 7 Replies View Related

How To Auto Load(on Start) A Form In Access 2000?

Jun 17, 2005

Hi guys. I have some forms in my access database and i want load one of it automatically
when i double click on my access.mdb . I be happy if some one teach me how i can do that.Thanks

View 2 Replies View Related

Start-up Query After Log-in

Apr 23, 2008

In my db I have a password log-in for each user. During the log-in process, I have a query set to run:

Code:SELECT tblSetOut.LogNum, tblSetOut.WoNum, tblSetCont.SetContName, tblSetOut.OrdAssign, tblSetOut.WoStat, tblSetOut.ThirdParty, tblSetOut.DateIn, tblSetOut.DateOut, tblSetOut.ThirdTimeIn, tblSetOut.ThirdTimeOut, (DateDiff("n",[ThirdTimeIn],[ThirdTimeOut]))/60 AS [Release if Greater than 24]FROM tblSetCont INNER JOIN tblSetOut ON tblSetCont.SetContInitials = tblSetOut.SetContInitialsWHERE (((tblSetOut.WoStat) Not Like "released" & "*") AND ((tblSetOut.ThirdParty)=True));
It opens up in read-only form that the user can print or exit out of.

What I need to happen is for the query to run based on the user's log-in name. There are three tables involved (tblSetOut, tblSetCont, and tblSecurity). The tbl SetOut and tblSetCont are joined at the field SetContInitials. The tblSecurity (field SC_NAME) is joined to tblSetCont at SetContName.

For the life of me, I cannot figure out how to capture the log-in name to filter the query.

Thank you in advance

Camille

View 6 Replies View Related

Convert Access 2000 Database To Access 2003

Sep 27, 2006

Hi,

A few years ago I’ve made an access database on access 2000. The problem is that now I’ve installed the office 2003, and I can’t make the database work properly.

At first says that are missing those files: “tshoot.ocx”, “msioff9.ocx” and “msowc.dll”; so, I’ve copy them from another computer using office 2000 and now only complains about “msioff9.ocx” saying that my database contains a reference incomplete to it.

Is there no other way to convert my database do work properly with access 2003? What can I do?

Regards

View 2 Replies View Related

Query Start And End Dates

Jul 26, 2007

I'm new in Databases and Access, so my problem is very simple.
I have a table with three fields: Name (Prim. Key), Start Date (Prim. Key) and Cost.

I want to obtain a query with this fields:
Name
Start Date
End Date (where the End Date would be one day before the next start date)
Cost


Thank you

View 1 Replies View Related

Newbie Dont Known Where To Start My Query

May 28, 2006

Hello, Really hope someone can help me.
I have 2 lots of info in 1 table - nameley customer address & posting address

I need to print a form that always has the posting address on the same side. but in some cases if the postal address is the same as the customer address then it is not filled in. hope this makes sense:

Please Im Really stuck

View 2 Replies View Related

Pass Rpt Start And End Dates To Query

Nov 25, 2005

I'm a couple of years removed from Access and shaking off the rust. I hope someone can help with something that may be obvious but I'm missing.

I'm simply looking to pass the begin and end dates to a query driving reports. The calendar form includes unbound text boxes, txtBeginDate and txtEndDate. My code populates the text boxes correctly; the user clicks on the calendar date, clicks the calendar day, then the Begin (or End) Date control, and each populates the respective textbox.

But when I run the query or report, I'm prompted for the parameters. This is what I have in the query's Date field criteria:

Between [Forms]![frm_Calendar]![txtBeginDate] And [Forms]![frm_Calendar]![txtEndDate]

I'm just drawing blank on what I did several years ago to make this work. If anyone can help, I'm most appreciative.

View 6 Replies View Related

Convert Access

Feb 16, 2008

Hello

It been a while since i have been on the forum. I developed a database last year and since then i have moved to a MAC.

I would like to know if there is a quick and easy way of converting a database to application which works on any PC or MAC which does not have access?

View 2 Replies View Related

Convert Access To Web

Mar 11, 2005

Can anyone tell me the best and easiest way to convert an
existing ms access database to run on the web.

I am just a beginner at this so please tell me in simple terms.

thanks

View 1 Replies View Related

Query That Finds Parts That Start With * Wildcard

Feb 26, 2007

I have a sales invoice table that contains parts that start with *, for example *SPR362.

I need to select only those parts that start with the *, as this is the wildcard in queries how do i select those products that start with it without it being recognised as the wildcard and selecting all records?

The field name is simply: Part

:o

Many Thanks

View 4 Replies View Related

Query Calculating No Of Days Between Start And End Date

Mar 20, 2007

i am trying to run a query from a form which will bring up the no of days difference between the start and end date also on the same form.
The query doesn't bring back any results can someone please guide in what i am doing wrong.
Here is the query
SELECT DateDiff('d',[start date],[end date]) AS [no of days]
FROM [booked property]
WHERE ((([booked property]![start date])=[forms]![booking]![booked property]![start date]) AND (([booked property]![end date])=[forms]![booking]![booked property]![end date]));

Thanks

View 2 Replies View Related

How Do I Start Thinking About This Multiple Criteria Query?

May 29, 2007

Embarrassingly, I'm not even to the point where I can ask a specific question about the query(ies) I think I need.

Here's where I'm starting from and where I want to go... maybe it will make enough sense for somebody to point me in the right direction.

I have sales data that contains line items for every item sold over the past X number of years. For each line, there are six key attributes that I'm concerned with.

For simplicity here's a scaled down example of the data for each line.

PART, PART_FAM, TRANS_DATE, FAM_GROUP, TRANS_AMT, OVS_CODE

For each attribute, there are at least five possibilities.

I have been asked to find monthly sales trends on about 20 unique combinations of these various attributes. An example might be, the monthly sales totals for:


TRANS_DATE = 1/1/06 to 1/31/06
PART_FAM = PIN
FAM_GROUP = 01xx
OVS_CODE = 2

Then a SUM for the TRANS_AMT.


I've set up a query that can give me the information I'm looking for one month at a time, but I want to believe there is a way to have Access do some of the grunt work, rather than me having to change the variables one by one and copy/paste each result into my new file.

Is there some reading or previous posts I could review that might get me thinking about this in the right way?

Thanks in advance!

View 2 Replies View Related

How To Stop Query Execution At The Form Start

Dec 19, 2005

Hi

I am a new user to Access. I created couple of forms using wizard, but when I view them, they show me all the available data by default. I want to stop this, if anyone can help me plz.

RMA

View 5 Replies View Related

SQL Command Convert Into Access

Dec 15, 2011

select Saler, Model, Price, DDate
from DB_Table where DDate in

(select max(DDate) from DB_Table where Valid = 'ok' group by Saler, Model)

How can I make it work in ms access 2007? I am trying to get valid (ok) price for Saler-Model group at max date.

View 4 Replies View Related

Queries :: Possible To Force A Query To Start Table Search At End?

Jan 24, 2014

As the post title says, is it possible to force a query to start its table record search at the end of the table and go backwards? The table I'm searching has hundreds of thousands of records and I want to check if any new records have a field with a value that has already been imported into the table. The duplicates would most likely occur near the end of the table and not the beginning, so I see no reason to waste cycles searching records from the very first record in the table.

View 14 Replies View Related

Please Help Me Convert Access 2003 Db To 2000

Aug 24, 2005

It's not letting me open it since i did it in 2003, and im trying to open it now at home in 2000.
I'd really appreciate if anyone can help me convert it and then attach it...thanks :o

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved