Can I keep my queries in the C drive and execute it against tables that are in the LAN network drive ? Right now the queries are also in the netowrk drive. So each time when I refresh the data into C drive, I have to import the queries too.
Is it possible to keep the queries in the C drive and execute against data in the netowrk ? Please let me know.
My workaround was to temporarily map the URL to a vacant drive letter on the local machine, then copy the file over, then drop the mapped drive again. A bit clunky but doesn't incorporate much of a delay and this download only has to happen once per day.
The good news is, the file download / copy now works every time. The bad news is that removing the temporarily mapped drive after the copy has taken place, doesn't and I can't figure out why.
Here are the functions I use to map / unmap the drive :
Code:
Option Compare Database Option Explicit
Private Const RESOURCETYPE_ANY = &H0& Private Const CONNECT_UPDATE_PROFILE = &H1& Private Const RESOURCE_CONNECTED As Long = &H1&
[Code] .....
I have separate functions to check existing drive mappings on the local machine and thus determine an appropriate vacant letter to use for the temporary mapping - they work fine.
Unfortunately the UnMapDrive function returns False (even though I switch the active drive to C: and force the connection to be cancelled with the fForce flag) So the mapping always remains on the users profile.
I don't want to permanently map drives on the users' profiles, just briefly for the purposes of this daily file download.
Is there a way to execute two statements in one query in access? I tried the following but received the following: "Characters found at the end of the SQL statment".
Here is what I have in my qryUpdateRecords file:
"UPDATE dbo_CE, tblCE_Details SET tblCE_Details.LIC_NUMBER = [dbo_CE].[LICENSE_NUM], tblCE_Details.Credit_Hours = [dbo_CE].[CREDIT_HOURS], tblCE_Details.Course_Sponsor = [dbo_CE].[COURSE_SPONSOR], tblCE_Details.Course_Name = [dbo_CE].[COURSE_NAME], tblCE_Details.Auth_Code = [dbo_CE].[AUTH_CODE], tblCE_Details.Category = [dbo_CE].[CATEGORY], tblCE_Details.Course_Date = [dbo_CE].[COURSE_DATE], tblCE_Details.ImportDate = Now() WHERE ([dbo_CE].EXPORT_TIMESTAMP IS NULL ) ; UPDATE dbo_CE SET([dbo_CE].EXPORT_TIMESTAMP = NOW() WHERE ([dbo_CE].EXPORT_TIMESTAMP IS NULL);"
This fails to run as the expression is too complicated, I suspect this is because a lot of the records will not have a [lastduration] and its therefore null. I have ran the code below sucessfully. expr:dateadd("d", 1,[lastlandingslot])
How can I get this to execute only if the [lastduration] is not null??
SELECT FCST.REF_DT AS [Date Forecasted], ACTUAL.REF_DT AS [Date Shipped], FCST.QT AS [Qt Forecasted], ACTUAL.QT AS [Qt Shipped], FCST.PART_NR, FCST.REGION, FCST.TYPE, IIf(FCST.QT=0,'',formatpercent((ACTUAL.QT-FCST.QT)/FCST.QT,2)) AS MPE
FROM TBL_FCST_WKLY AS FCST, TBL_ACTUAL_WKLY AS ACTUAL
WHERE (FCST.TYPE=ACTUAL.TYPE) AND (FCST.REGION=ACTUAL.REGION) AND (FCST.PART_NR=ACTUAL.PART_NR) AND
FCST.REF_DT = (SELECT DISTINCT DATEADD("ww",-LT.LEADTIME,ACTUAL.REF_DT) AS FORECASTED FROM TBL_FCST_WKLY FCST2 INNER JOIN LEADTIME LT ON LT.COMPONENT=FCST2.PART_NR AND LT.REGION=FCST2.REGION WHERE FCST2.PART_NR=FCST.PART_NR AND FCST2.REGION=FCST.REGION) AND
FCST.MONTH_DT = (SELECT DISTINCT DATEADD("ww",LT.LEADTIME,FCST.REF_DT) AS FORECASTED FROM TBL_FCST_WKLY FCST2 INNER JOIN LEADTIME LT ON LT.COMPONENT=FCST2.PART_NR AND LT.REGION=FCST2.REGION WHERE FCST2.PART_NR=FCST.PART_NR AND FCST2.REGION=FCST.REGION);
i am querying two tables TBL_FCST_WKLY which has 29500 records and TBL_ACTUAL_WKLY which has 798222 records. When i run this query it sites there forever. Is it because i dint optimize my query or is it because the number of records is too much for access? can someone help plz.
Because my tables were already large I split them up by environment to speed up data maintenence and retrieval. Thus I have table names which contain the environment as part of the table name (ex: tbl_TEST_MyTable, tbl_PROD_MyTable). Once the user sets the environment they want to use (by clicking on an option button) I update the form's recordsource to the appropriate table. My form has 5 subforms within it.
Even with the split loading the form was taking a long time because some of the queries the subforms are based on are joining tables so that they can be linked (parent/child) to the form. I created indexes to speed up the data access which helped a little but it was still running too slow. So, I attempted to change the subform's queries to only join the necessary data by re-creating the queries each time the user changes the form's current record.
For example, what I had originally was taking too long:
SELECT DISTINCT tb.*, pt.CollId, pt.ProgName, pt.QueryNo FROM tbl_TEST_SysTables AS tb INNER JOIN tbl_TEST_Plan_Table AS pt ON tb.Name = pt.TName ORDER BY tb.Name;
and the parent/child link fields are CollId, ProgName, and QueryNo.
This is the change I made:
SELECT DISTINCT tb.*, pt.CollId, pt.ProgName, pt.QueryNo FROM tbl_TEST_SysTables AS tb INNER JOIN tbl_TEST_Plan_Table AS pt ON tb.Name = pt.TName WHERE pt.CollId = 'BATCH_COLLECTION' AND pt.ProgName = 'PROGRAM1 AND pt.QueryNo = 123 ORDER BY tb.Name;
where the pt fields are changed dynamically each time the user navigates to the next record in the form. This resulted in much faster access time; however I discovered that the form was always displaying the query that existed before the form was opened. I have not been able to figure out how to get the subforms to display the latest created query.
While debugging I discovered that the form's OnCurrent event was being executed 3 times before the form is opened. I don't know what I'm doing that's causing this.
I also discovered that the subform events are executed before the form's events, so I think that's why the latest query isn't being used. I attempted to requery the subform in the form's OnCurrent and OnOpen event, but to no avail.
I have a list box (1L) in a form (1F) that list member IDs from a table. Then I have a query (1Q) that use (1L) member ID to get data from a table another related table. When I change the 1L and run the query 1Q the results is correct. So I added a new list box (2L) in form 1F that show the results of the query. When I open the form 1F the 2L is populated correctly by the query. Here is my problem. I need to have list 2L update when I change 1L. Here is what I did. I created an On Change event for 1L that has a code Me.2L.Requery, but nothing happens.
A new query I am building, after entering an expression, gave the " You tried to execute a query that does not include the specified expression.." error. The new query is based on and uses expressions from another query. The error message listed the expressions from the query upon which this query was based. Copying in all the fields referenced in the error message did not work.
Here is the SQL code, the offending expression in red:
SELECT [Test Grade Results].[Class Number], [Test Grade Results].StudentNumber, Count([Test Grade Results].[Test Number]) AS [CountOfTest Number], Avg([Test Grade Results].[41Grade]) AS AvgOf41Grade, Sum([Test Grade Results].Wghtd41) AS SumOfWghtd41, [GPA]=Sum([Test Grade Results]![Wghtd41])/[Test Grade Results]![CuumWeightDivisor] AS Expr1FROM [Test Grade Results] INNER JOIN [Test Parameters] ON [Test Grade Results].[Test Number] = [Test Parameters].TestNumberGROUP BY [Test Grade Results].[Class Number], [Test Grade Results].StudentNumber;
Wghtd41 is the expession that is included in the error message.
This is the SQL from a query for a Payroll report. It was an already existing report, so I'm trying to modify it to meet the business's needs. The problem is that there are multiple entries for WOLabor.Hours for a given day. These entries come from the invoicing program when a mechanic's hours are logged for billable time. So there may be 3 hours here and 1.5 hours there...but all for the same day. Payroll is just concerned with total hours worked...so I'm trying to combine all the hours for a given day into one variable or something and use that. I know this is long, but apparently a lot of fields are involved:
THIS GIVES ME NO ERRORS:
Code: Original - Code SELECT Person.LastName, WOLabor.MechanicNo, WOLabor.WONo, WOLabor.Hours, WOLabor.MechanicName, WOLabor.DateOfLabor, WOLabor.LaborRateType, WOLabor.SaleDept, WOLabor.SaleCode, IIf(WoLabor!laborratetype="R",IIf(wolabor!salecode<"P",[Hours],0)) AS Regular, IIf([regular] Is Null,0,[regular]) AS Reg, IIf(WoLabor!laborratetype="P",[Hours],0) AS [Double], IIf(WoLabor!laborratetype="O",[hours],0) AS Overtime, IIf(wolabor!salecode="R",[Hours],0) AS Holiday, IIf(wolabor!salecode="V",[Hours],0) AS LT, IIf(wolabor!salecode="U",[Hours],0) AS npay, IIf(wolabor!salecode="T",[Hours],0) AS Sick, IIf(wolabor!salecode="P",[Hours],0) AS Meet, IIf(wolabor!salecode="S",[Hours],0) AS vac, IIf([Hours]<=8,[Hours],8) AS PayrollReg, IIf([Hours]>8,[Hours]-8,0) AS PayrollOT, SaleCodes.LaborDescription, WOLabor.Cost, WOLabor.Sell, Person.Branch, Branch.Name, Dept.TitleFROM (((WOLabor INNER JOIN SaleCodes ON (WOLabor.SaleBranch=SaleCodes.Branch) AND (WOLabor.SaleDept=SaleCodes.Dept) AND (WOLabor.SaleCode=SaleCodes.Code)) LEFT JOIN Person ON WOLabor.MechanicNo=Person.Number) INNER JOIN Branch ON SaleCodes.Branch=Branch.Number) INNER JOIN Dept ON (SaleCodes.Dept=Dept.Dept) AND (SaleCodes.Branch=Dept.Branch)WHERE (((WOLabor.DateOfLabor)>=[Start Date] And (WOLabor.DateOfLabor)<DateAdd("d",1,[End Date])) AND ((Person.Branch) Like IIf([Enter the Branch Number or "All" for all:] Like "A*","*",[Enter the Branch Number or "All" for all:])) AND ((WOLabor.Transfer)=False))ORDER BY WOLabor.SaleDept, WOLabor.SaleCode; SELECT Person.LastName, WOLabor.MechanicNo, WOLabor.WONo, WOLabor.Hours, WOLabor.MechanicName, WOLabor.DateOfLabor, WOLabor.LaborRateType, WOLabor.SaleDept, WOLabor.SaleCode, IIf(WoLabor!laborratetype="R",IIf(wolabor!salecode<"P",[Hours],0)) AS Regular, IIf([regular] Is Null,0,[regular]) AS Reg, IIf(WoLabor!laborratetype="P",[Hours],0) AS [Double], IIf(WoLabor!laborratetype="O",[hours],0) AS Overtime, IIf(wolabor!salecode="R",[Hours],0) AS Holiday, IIf(wolabor!salecode="V",[Hours],0) AS LT, IIf(wolabor!salecode="U",[Hours],0) AS npay, IIf(wolabor!salecode="T",[Hours],0) AS Sick, IIf(wolabor!salecode="P",[Hours],0) AS Meet, IIf(wolabor!salecode="S",[Hours],0) AS vac, IIf([Hours]<=8,[Hours],8) AS PayrollReg, IIf([Hours]>8,[Hours]-8,0) AS PayrollOT, SaleCodes.LaborDescription, WOLabor.Cost, WOLabor.Sell, Person.Branch, Branch.Name, Dept.TitleFROM (((WOLabor INNER JOIN SaleCodes ON (WOLabor.SaleBranch=SaleCodes.Branch) AND (WOLabor.SaleDept=SaleCodes.Dept) AND (WOLabor.SaleCode=SaleCodes.Code)) LEFT JOIN Person ON WOLabor.MechanicNo=Person.Number) INNER JOIN Branch ON SaleCodes.Branch=Branch.Number) INNER JOIN Dept ON (SaleCodes.Dept=Dept.Dept) AND (SaleCodes.Branch=Dept.Branch)WHERE (((WOLabor.DateOfLabor)>=[Start Date] And (WOLabor.DateOfLabor)<DateAdd("d",1,[End Date])) AND ((Person.Branch) Like IIf([Enter the Branch Number or "All" for all:] Like "A*","*",[Enter the Branch Number or "All" for all:])) AND ((WOLabor.Transfer)=False))ORDER BY WOLabor.SaleDept, WOLabor.SaleCode; When I make the following changes to the SELECT section, I get this error:
You tried to execute a query that does not include the specified expression 'LastName' as part of an aggregate function.
Code: Original - Code ... IIf(Sum([Hours])<=8,Sum([Hours]),8) AS PayrollReg, IIf(Sum([Hours])>8,Sum([Hours])-8,0) AS PayrollOT, ... ... IIf(Sum([Hours])<=8,Sum([Hours]),8) AS PayrollReg, IIf(Sum([Hours])>8,Sum([Hours])-8,0) AS PayrollOT, ... Any insight is greatly appreciated.
UNION Query will not execute properly. Remove "WHERE" statement query runs.The WHERE statement is used to locate all duplicate records, based on serial number, in a table. Also, it excludes certain data contained in two of the four tables. There are four separate queries for four separate tables. They all work until incorporated into a UNION QUERY.
Question, is there another way to structure the "WHERE" statement for this UNION Query and achieve the same results?
I am getting the following error message in strsql:You tried to execute a query thats does not include the specified expression 'ScanDate=20140730 and SCanhour=8' as part of an aggregate function in the following strsql.
Code: Call func1("Z", 8) Public Sub func1(b As String, a As Integer) strsql = "SELECT Count(BatchNo) AS CountOfBatchNo, Sum(Envelopes) AS SumOfEnvelopes, Sum(Cases) AS SumOfCases, Sum(Pages) AS SumOfPages, ScanDate, [Type] & Format([Type1],'00') & Format([Type2],'00') AS QueueNo " _ & "FROM jabberwocky " _ & "group By ScanDate, [Type] & Format([Type1],'00') & Format([Type2],'00') " _ & "HAVING ScanDate=" & J & " and Scanhour=" & a & "" End SUb
I have a combobox iBrand on a form frmFoodSub with the following query used to get its values (based on the imput of another combobox, iProduct, linked to the field Product in the table Products.) This code was generated by query builder, not myself:
Code:SELECT Products.BrandFROM ProductsWHERE (((Products.Product)=[Me]![frmFoodSub].[form].[iProduct]))GROUP BY Products.BrandORDER BY Products.Product;
And I keep getting this error message when the combobox is in focus on my form:
You tried to execute a query that does not include the specific expression 'Products.Product' as part of the aggregated function.
I have no idea what started this error. It was all working fine and then all of a sudden the error started appearing and I can't remember making any changes to cause it.
I have a form which I want to load before it starts up a vba function. How can I do that? Right now I use form_load(), but the problem is that, it loads the msgbox before loading form.
Code: rivate Sub Form_Load() Dim sFolderSpec As String, sCSVSource As String, dFileDate As Date sCSVSource = "MDM_Syndicator.csv"
Hi, I have been reading through the forum and found alot of really interesting stuff but cannot seem to find the answer to my specific problem. I'm sure it's easy but i'm sick of trying to figure it out now.
I am trying to build a form to display a shift rota. My tables contain daily shift patterns for 6 staff members for 2007. I want to build a form that has a subform displaying the rota for a particular analyst and a control in the master form to select which of the 6 staff members you wish to view. I have built a master form with a combo box. The combo box holds the names of the six staff and gets this data with a select statement in the Control Source field from the employee table. I constructed this with the wizard. I have constructed a query to drive the sub form. The query builds the rota, getting data from my tables but gives all shifts for all dates for all staff . I want to restict this in my subform to all shifts for all dates but for 1 member of staff. The member of staff should be defined by the selection made in the combo box in the master form. I then have a statement in the criteria of the query driving the subform to restrict the results by name to the name selected in the master form combo box. I'm sure this should work as i have used similar methods in the past. The statement in the query criteria reads like this:
[forms]![frmRota].[cmbAnalystSelect]
this is in the field of analystName, so the criteria should find all instances where the value in the analystName field matches the value in the cmbAnalystSelect control. However, the query always returns no results.
When i run the quey i have already opened the form (frmRota) and selected a value for cmbAnalystSelect, so the quey should collect the value from the combo box and filter the result according to the criteria but it seems to filter out all the results. If i run the query without first opening the frmRota form then i am prompted by a dialog box to enter a value for [forms]![frmRota].[cmbAnalystSelect]. If i enter a corresponding correct value (a valid name for a member of staff) the query returns a correct set of results, i.e. all shift patterns for all dates for the selected member of staff. When i have the form already opened i am not prompted for a value by the dialog box which would suggest it is at least recognising the form is open and that the control is there.
The last thing is that my ComboBox control is not bound to anything, when i view the control in design view it says it is unbound. I have nothing in the control source for the ComboBox. In the row source i have a select statement to pick out the employee names from the employee table, this then poulates the list in the ComboBox.
I hope this is enough info for someone to understand my problem and offer some advice, i can elaborate, attach screen shots etc. if needed.
I have an exrternal shared drive "E:"where I put my be files (which are constantly accessed by users with fe's from different terminals). Everytime I reboot the computer that I am working on (where the external drive is), I have to set up the permissions of the shared drive "E:" all over again, otherwise other computers have no access to E. Is there a way that I could fix this and not having to set permissions every time I reboot my computer? For some reason, the permissions are lost.
I have a db on a network drive and the performance is terrible, it runs fine on my local machine. How can I make it run better? The db is only 2 megs so I figured it would be ok, but since my forms have numerous queries within them, performance stinks.
Does anyone know if Access has a built-in control that allows users to scan the directory structure of their PC? Similar to the DriveListBox and DirListBox controls in VB6? If so, how might I get access to it?