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'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
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 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 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.
I am trying to create an access database to allocate people to projects and show the total time spent on projects. As peoples time can be allocated to different projects I want to add up the proportions of their times per day and show the results in a graph.The data I am entering is the date they start working on a project (Start date), the date they stop (End date) and their time allocation (e.g. 50%). How can I use this data to sum for date ranges?
I have attached an example database showing the problem. In the report the graph shows the type of thing I want for the output, clearly showing the total time spent on a project is more than 100% on one day and less on another day. Do you know how I can do this?
Is there any way of entering a mixture of subscript, superscript and normal characters in Access. I am trying to enter subscript numbers into a database of mineralogical formulae.
I am trying to write a function in an access 2007 query that will calculate the date range for each of my records based on the month-ending date and the In-transit days assigned to each record (excluding any weekend days) (i.e. if the in-transit days number is 5 & the month ending date is 5/26/12 then my date range would be 5/22/12-5/25/12). I want the funtion to calculate the range, I cannot use parameters as each record will have a different range based on it's in-transit days .
I have the following function which works well except when I want to run a search using date range and any other criteria on another text/listbox or combo box.
This is work i get in the immediate window (Where Status, TypeID, PurposeID are the other criterias used with the date range.):
Code: WHERE ([Incident_Date] Between #02/06/2012# AND #02/06/2012#)[Status] LIKE '*Active*' AND [TypeID] Like '*1*' AND [PurposeID] Like '*2*'
And the Build Function is as follows:
Code: Private Function BuildFilter() As Variant Dim varWhere As Variant Dim strField As String 'for the date field varWhere = Null ' Main filter
I want to make a delete query, which delete record between certain dates, I want access to ask user to specify range of date before executing the query.
Is their a way to update the TotalBatches in TableA with the sum of NumBatches from tableB that have the same BatchType and falls between the FromDate and ToDate of TableA?
Is there a font that comes installed by default in access(windows) that supports subscript? My subscript in access is showing up as a box. If I change it to a font that I have installed/purchased seperate from windows it gets displayed properly. The problem with this, is when it pulls this info displayed in that font to the website, it reverts it to a font that the user doesn't have installed and goes back to a box.
So need a default windows xp font installed in access/windows that supports subscript....
I have a list of customers with multiple rent start and end dates. I need to create a query where each customer will have a record for every month/year between their respective rent start and end dates. I generally use macros but can't figure out a way to do it without VBA. My field names are Rent StDt and Rent EndDt. My query name is QCalcREndDt. I use version 2010.
I am looking to have entries made to the table based on a date range. I have a database of events and most repeat daily, weekly, etc. When I enter them into Access, they go in as a single entry with a start and end date. But I need to have them as individual entries for each day so that rather than one entry of 5 days, I need to create 5 entries of one day each.
if it is possible to store text in a table that includes subscript / superscript characters. As an example; need to indicate the units of measurement for some data and therefore need to be able to pull data from the table such as the following: kg/m2, m/s2 etc. In both these case i need the 2 character to be superscript.
I'm trying to make this an automated process so pulling it directly from the database.o a method of storing the data as a text string would be ideal.Otherwise i imagine a rather difficult VBA function will be involved
I have the following project that works as a timesheet manager:
Users enter in a form the employee name/date/hours worked/role/overtime (yes or no)/rate... on a daily basis. At the end of every week, they must create a report depending on the dates given in a query.
I have only one table (tbl_EmployeeHours) and a query to calculate the number of hours between two dates.
At the moment a report gives me all the information above (employee name/date hours worked etc..) but what I am trying to is a bit different.
I need Access to create a report (based on a date range given by the user) that would give me: per unique name, the number of normal hours worked in total, next column, the number of hours worked as overtime (rate 1.5), then, the number of hours worked as overtime (rate 2).
This means there are 3 different totals. For example, in the date range given, someone might appear twice but in the report he will appear only once with 3 different totals...
My guess:
I would say I need to create a different query for the 3 different totals (normal hours, overtime 1.5 and overtime 2). For each query you would need to ask the user to input the date range (which would not be so user-friendly I agree...). Then, I am not sure how access would create that list of names and combine the 3 different results from the queries...?
I have a client that wants to enter a range of dates in a query of when they will call that person back. Then they want to be able to type in a range of dates and have a make table query show them all the people that fall in between these two dates....is this even possible??? Ex. Joe March 3 to March 8 Mary March 4 to March 9 John March 5 to March 10
So if they type into the query March 3 to March 6 all three people should show up because one of the dates specified lies within the parameters they are asking for.....man I am out of ideas
As part of a larger issue, I am trying to figure out how to have an Access 2000 select query produce all dates in a date range into one field on the query. Assume at this point there are no tables in the query.
If 01/01/06 (mm/dd/yy) and 02/01/06 is used, then it'd list all the dates between those two, inclusive.