Reports :: Subscript Out Of Range In Report Wizard
Sep 10, 2013
I am trying to generate a report from a select query using the report wizard. The wizard is showing the error of subscript of out range. What is the reason and how can be rectified?
I'm attempting to upload an excel file into access table using the wizard however I get this error message "subscript out of range" Please Help! I've uploaded other files via excel and don't have this problem.
Ok I have the following code which keeps producing an Error # 9 : subscript out of range.....
Public Sub SaveLineItems() On Error GoTo SaveLineItem_Error MsgBox "I am doing the line items" Dim sSQL As String Dim iLine As Integer Dim iMaxLines As Integer Dim iMonthCount As Integer Dim iFieldCount As Integer Dim sThisField As String Dim sFieldPrefix As String Dim aFields, aMonths, sInDirectCostId, sFY, sUser sFY = [Forms]![SWITCHBOARD]![cboFY] sUser = [Forms]![SWITCHBOARD]![txtUser] sInDirectCostId = sFY & sUser aFields = Array("cboDesc", "txt", "txtMemo") aMonths = Array("OCT", "NOV", "DEC", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP") iMonthLoop = 0 iMonthCount = 11 iMaxLines = 16 iLine = 1 Do While iLine <= iMaxLines iMonthLoop = 0 If Me.Controls(aFields(0) & iLine) <> "" And Me.Controls(aFields(0) & iLine).Locked = True Then If Me.Controls(aFields(0) & iLine).Column(2) = -1 And Me.Controls(aFields(3) & iLine) = "" Then MsgBox "You must have a memo for the program : " & Me.Controls(aFields(0) & iLine), vbOKOnly, "Missing Information" Me.Controls(aFields(3) & iLine).SetFocus Exit Sub Else sSQL = "UPDATE BUDGET_INDIRECTCOSTS_R_LINEDETAILS SET " & _ "ProgramId = " & Me.Controls(aFields(0) & iLine) & ", " & _ "Memo = " & Me.Controls(aFields(2) & iLine) & ", " Do While iMonthLoop <= iMonthCount sSQL = sSQL & aMonths(iMonthLoop) & " = " & Me.Controls(aFields(1) & aMonths(iMonthLoop) & iLine) If iMonthLoop < iMonthCount Then sSQL = sSQL & ", " End If iMonthLoop = iMonthLoop + 1 Loop sSQL = sSQL & " WHERE INDIRECTCOSTID = " & sInDirectCostId & " AND ID " = iLine End If ElseIf Me.Controls(aFields(0) & iLine) <> "" Then If Me.Controls(aFields(0) & iLine).Column(2) = -1 And Me.Controls(aFields(3) & iLine) = "" Then MsgBox "You must have a memo for the program : " & Me.Controls(aFields(0) & iLine), vbOKOnly, "Missing Information" Me.Controls(aFields(3) & iLine).SetFocus Exit Sub Else sSQL = "INSERT INTO BUDGET_INDIRECTCOSTS_R_LINEDETAILS " & _ "(Id, ProgramId, Memo" Do While iMonthLoop <= iMonthCount sSQL = sSQL & ", " & aMonths(iMonthLoop) If iMonthLoop = iMonthCount Then sSQL = sSQL & ") VALUES (" End If iMonthLoop = iMonthLoop + 1 Loop iMonthLoop = 0 sSQL = sSQL & "" & iLine & ",'" & Me.Controls(aFields(0) & iLine) & "','" & Me.Controls(aFields(2) & iLine) & "'" Do While iMonthLoop <= iMonthCount sSQL = sSQL & ", " & Me.Controls(aFields(1) & aMonths(iMonthLoop) & iLine) If iMonthLoop = iMonthCount Then sSQL = sSQL & ")" End If iMonthLoop = iMonthLoop + 1 Loop End If End If MsgBox sSQL If Len(Trim(sSQL)) > 0 Then Set db = CurrentDb db.Execute sSQL End If iLine = iLine + 1 Loop SaveLineItem_Error: If Err.Number <> 0 Then MsgBox "Line Item Save Error : " & Err.Number & vbCrLf & Err.Description End If End Sub
I have gone through and commented everything out and brought back only parts and here is what I have when I get the error the first time....
Public Sub SaveLineItems() On Error GoTo SaveLineItem_Error MsgBox "I am doing the line items" Dim sSQL As String Dim iLine As Integer Dim iMaxLines As Integer Dim iMonthCount As Integer Dim iFieldCount As Integer Dim sThisField As String Dim sFieldPrefix As String Dim aFields, aMonths, sInDirectCostId, sFY, sUser sFY = [Forms]![SWITCHBOARD]![cboFY] sUser = [Forms]![SWITCHBOARD]![txtUser] sInDirectCostId = sFY & sUser aFields = Array("cboDesc", "txt", "txtMemo") aMonths = Array("OCT", "NOV", "DEC", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP") iMonthLoop = 0 iMonthCount = 11 iMaxLines = 16 iLine = 1 Do While iLine <= iMaxLines iMonthLoop = 0 If Me.Controls(aFields(0) & iLine) <> "" And Me.Controls(aFields(0) & iLine).Locked = True Then If Me.Controls(aFields(0) & iLine).Column(2) = -1 And Me.Controls(aFields(3) & iLine) = "" Then MsgBox "You must have a memo for the program : " & Me.Controls(aFields(0) & iLine), vbOKOnly, "Missing Information" End If ElseIf Me.Controls(aFields(0) & iLine) <> "" Then If Me.Controls(aFields(0) & iLine).Column(2) = -1 And Me.Controls(aFields(3) & iLine) = "" Then MsgBox "You must have a memo for the program : " & Me.Controls(aFields(0) & iLine), vbOKOnly, "Missing Information" End If End If iLine = iLine + 1 Loop SaveLineItem_Error: If Err.Number <> 0 Then MsgBox "Line Item Save Error : " & Err.Number & vbCrLf & Err.Description End If End Sub
I have gone and researched the problem and have not been able to find anything that relates to this......
The below code exports a table (via a function) to a spreadsheet and saves it in a defined location. the code then opens the file does some work with it then moves it(left the move bit out as it works fine)
so when i run the code it works absolutle fine, table is exported, work is done and file is moved. however if i run the code again it fails, i get the error message out of range. i was originally getting this error when using the .usedrange.copy so i commented this out and now i get it on the next line that tries to work with the file so obviously something is wrong in my logic.
Code: Private Sub Export2JDE_Click() Application.Run ("JDE_Export") 'Exports to an xlsx file in the location described in the function. Dim xlApp As excel.Application Set xlApp = CreateObject("Excel.Application") xlApp.Visible = True
When I try to import a sheet from Excel into an existing table I get a subscript out of range error.When I then import the sheet into a new table and then import it into the existing table I was trying above immediately afterwards it works fin.
I am trying to import data from Excel 2007 to Access 2007. However, after hitting the final button to submit the import I get this message: "Subscript out of range."
I have tracked down the fields that seem to be causing the problem. Below is a picture of the Design View for my table. The fields named Ht, College, Dob, State, and Country are the fields that give me the subscript message (I know this because I tried uploading different times with just one of these fields mixed in with the fields that would upload). My first guess for the Height was just a matter of the data type being wrong, but I changed the Ht column to text on my Excel spreadsheet and the same message occurs.
College: Is listed in the picture. This is being pulled from another table. I have another field labeled Transfer College that does this as well, but the expression is a bit different, and any data in a Transfer College column on excel will import over. I have tried altering the College data type to match the Transfer college, but I have to delete too many relationships and it screws up the record source for all of my forms and reports.
DoB: It has an input mask of: 99/99/0000;0;" " Not sure why this doesn't work. Access seems to be picky with dates. When going through the import steps it changes my dates in my spreadsheet to a 5 digit number.
State: Again, another combo box with a value list. State abbreviations are the record source. I would think this would upload. Should I just remove the combo box and value list for now, and then reset this after I transfer my data over?
Country: Another combo box, but this one is pulling its data from a table with countries listed.
Dim xlApp As New Excel.Application Dim xlwrkBk As Excel.Workbook Dim xlSheet As Excel.Worksheet Dim strXLS As String strXLS = "c:AccessMyfile.xls" Set xlwrkBk = xlApp.Workbooks.Open(strXLS)
[code]...
The program is stopping at " Set xlSheet = xlwrkBk.Worksheets("singles")"
and I am receiving the following error box:
Runtime error 9
Subscript out of range.
I don't understand this error because I am using the same program code with another Excel file in another module and it works perfectly.
I am having trouble checking if the last array value is equal to 'D'.
This is what i have so far but it keeps saying that 'subscript is out of range'... 'g' by the way is equal to 1. It just really means that there's only one value in ArrAC.
Trying to import data from Excel into an existing table in Access 2007. The import fails and keeps getting the error message: "subscript out of range". All of the column headings in the 1st row are exactly the same as the table in Access, and the data types are all text except for the key which is a number. I've imported to this table many times and not had a problem and can't figure this out.
The data the query pulls is employee name, course ID, course name and course completed date. I have added criteria in the query that asks for the Course ID to filter on a given course and a dynamic field in the query AnnualReqDate: DateAdd("d",+365,[TrainingCourseCompleted]). What this returns is a list of employees that have completed course X the date they completed and the date (12 months) when the course is due. This works great, have created a report that reflects this very well.
The issue comes in when I try to add the ability to filter by date range on the AnnualReqDate dynamic field. the AnnualReqDate dynamic field does not exist until the query is run the Between [Start Date] And [End Date] criteria add to the AnnualReqDate dynamic field wont work.The query fires off but returns zero records.
I have a report, based on a query, where the field name is "Date of Work". The criteria in this query field is >=[Start Date] And <=[End Date], which works fine. However I need to have the start and end dates to show in the resulting report header based on the query.
I am in the process of making some changes to an inherited database. One of the things I need to do is to fix an issue with the reports. The reports have a field which asks for the data range (from xx/xx/xx to xx/xx/xx) as soon as the report is opened, but then the query that fills that report also asks for the same data range so you end up entering it twice.
What do I need to do to enter the data range only once and have it show up on the report and also be used on the query?
What I have is a single table that I need to create a report from. It has vehicle unit numbers, dates of service, repair details and costs. I am trying to generate a report where I can select a unit from a combobox and enter a date range.
I am trying to pass a date range parameter & an additional parameter (Type of Audit) to 6 subreports based off individual crosstab queries and housed on one Unbound Report ("rptFinal").I have an Unbound Form "frmDate" passing a date range and Type of Audit using [Start Date] and [End Date] to rptFinal with a button that simply opens the rptFinal as follows:
In each Crosstab query, I have set the parameter criteria (in both the Parameter section & the query itself) to:
[Forms]![FrmDate]![Start Date] And [Forms]![FrmDate]![End Date] and also, [Forms]![FrmDate]![Enter Type of Audit]
On each subreports On Load Event, I have added:
Private Sub Report_Load() Me.Filter = "[DteAuditDate] BETWEEN #" & Forms!frmDate![Start Date] & "# AND #" & Forms!frmDate![End Date] & "#" Me.Filter = "[Type of Audit] = #" & Forms!frmDate![Enter Type of Audit] & "#" End Sub
and I've set the Filter On Load property to: Yes..I can open frmDate, fill in the date and Type of Audit, launch the report and it runs with no error, I have 6 blank subreports in report Preview. The headers are showing up but none of the data.
I want to make an unbound form that has the functionality like the form found in access for reports wizard.
I want the user to be able to select the sort order dynamically for a report instead of a fixed sort order. But i'am unable to sort out my own problem :mad:
plz check out the functionality of this form by opening in your access.
When the first combo is empty all the other combo boxes are disabled.
Entering something in the top combo enables the combo below it.
If we delete something in the top combo when something is already existing in the combo beolw it, the values of the bottom combo boxes are shifted to the upeer combos and the lower combos are disabled.
Howdy All!!! I am receiving the below error message: "You have chosen fields from record sources which the wizzard can't connect. You may have chosen fields from a table and a form a query based on that table. If so, try choosing fields from onluy the table or only the querry."
OK here is what is going on... I have a table that is linked to a *.txt file. This *.txt file comes from our AS400 and is the root of all my information. It has 2 pieces of information in it that I need to seperate out and then eventually join back together. It is a space delimited file. The 2 pieces of information are: 1) Header (Dates, Vessell, and Container information) 2) Body (Product information and qty of each Container)
The mapping looks like this: Header='ISPDD' 1- A Record Name = mid(1,5) [Ref. Example:ISPDD] 2- Unique Key = mid(6,7) [Ref. Example:0000001] 3- Container Number = mid(13,10) [Ref. Example:MK03000001] 4-Arrival Date = mid(23,8) [Ref. Example:06092004]
Body='ISPDT' 1- A Record Name = mid(1,5) [Ref. Example:ISPDT] 2- Unique Key = mid(6,7) [Ref. Example:0000001] 3- A item code = mid(13,6) [Ref. Example:007529] 4- A item color = mid(19,3) [Ref. Example:015] 5- Item Qty = mid(22,6) [Ref. Example:111111]
What I did is wrote 2 query's. One that looked at the *.txt file and produced results on [Like "ISPDD*"] to give me just the HEADER information. I then added the criteria from the space delimited mapping above. I did the same to pull out just the BODY information, again adding the criteria to the query from the space delimited mapping above.
Now that I have the two pieces of information, I want to run a report and combind the 2 together in a more reader friendly format. In doing so I received the error message above.
I then tried having the query's create a new table after they run (one Header Table and one Body Table). Once that completed I created a relationship between the 'UniqueKey Header' and 'UniqueKey Body'. This actually worked but, when I receive a new *.txt file and run the query it gives me read only/cannot delete files because of relationships. Needless to say I am in a bind. Hopefully I shared enough detail to help me with my problem. Many thanks in advance for the help. One other piece of info, This *.txt file can contain many headers and boddy information. I have received one that had at least 10 different Unique keys that had to be linked together.
When I try to use form/report wizard, I click on New, Form Wizard. Then I got form where I should pick fields for my form/report. But I have no one field on left side. Above I select Table but haven't any available field. I use Windows XP and Office 2003. Can anyone help me?
Hey can I transfer data into a report wizard, to have the wizard use that data instead of the data in a table or query?? This data would come from a form.
I know there is a Access Guru out there that could do this in a milisecond, but, this one has been kickin my backside all week...
I need to know how to create a shortcut button in a form to bring up the "Report Wizard" feature. Then after that button is created, I would like to be able to hide the structure of my database so that all the users can see is the switchboard. PLEASE give me some insight here if you can, the first correct reply gets free fries with thier next order...
I'm working on a db for work. On my Nav form, I have two tabs- each tab has cmd btns that open up different search or data entry forms. I also have a few reports that can be opened based on a query I created.
The last thing I want to add is a control/button that opens the query wizard so the user doesn't have to navigate to the "Create" tab of access. The reason behind this is that one user may not know how/where to find the query/report wizard.
Is there some VBA code or Macro I can create to add this functionality to a button ("Create New Report" or "Create New Query".)
I am looking to call two different queries from report wizard to produce report. Getting error message what to do in this situation as both queries are important as i have to pick all records from query A and just one record from query B any other option to get this in report.
I have a report called rpt_date_range it is based off of the query qry_date_range.
qry_date_range has "Between [Start Date] And [End Date]" in the criteria for the date field.
In the report header, I have the title "All records from [Start Date] to [End Date]"
What I want to do is to take what is entered into the [Start Date] and [End Date] and put that into the title in the report header. At the moment, I don't know how.
For example, I have 1 table with 3 fields : Name, Birth date, Gender. Then I want to create a report where all data are grouped by age range and gender