Database Query Does Not Return Any Data
Mar 15, 2007
I am using the attached code however when my database query does not return any data I dont want the Dim function to perform.
Sub macro3()
Worksheets("Data 1"). Range("I3:BU65536").ClearContents
'declare a variable to hold date
Dim strDate As String
strDate = Format(CDate(Range("startDate").Value), "yyyy-mm-dd") & " " & FormatDateTime(CDate(Range("startDate").Value), vbLongTime)
Sheets("Data 1").Select
Range("A1").Select
With Selection.QueryTable
.Connection = _...........................
View 4 Replies
ADVERTISEMENT
Nov 11, 2009
I need to create a new query that pulls data from a 2007 Access database into Excel 2007. When I invoke the 'From Microsoft Query' option after 'Data/From Other Sources', and then select 'MS Access Database*', the only file type presented is '*.mdb' . However, I need to pull from an '*.accdb' file type. I have both Office 2003 and Office 2007 installed.
View 8 Replies
View Related
Jan 17, 2007
I have an excel file that imports data from an access database. Now the user wants the database password protected I edited my code to include the line "user ID=admin;password=risk;" but I'm getting an error message stating: "Cannot start your application. The workgroup information file is missing or opened exclusively by another user."
I'm bothered because I did not create a workgroup information file. I just want a password on the database I did not create users and groups.
Note this code works fine without the password protection and the added line.
My
Sub Update_Click()
Dim rsData As ADODB.Recordset
Dim szConnect As String
Dim szSQL As String
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= C: est.mdb;" & _
"user ID=admin;password=risk;"
szSQL = "SELECT * from data"
Set rsData = New ADODB.Recordset
rsData.Open szSQL, szConnect, adOpenForwardOnly, adLockReadOnly, adCmdText
View 4 Replies
View Related
Nov 7, 2008
I'm trying to lookup a database named database and return a time in column A, based on criteria in cells a1 and b1 on another sheet, A1 would contain a number and B1 would contain a day from mon-fri
eg of Database
A B C D E F G
10:00 5000 Mon Tues
11:00 5000 Wed Thur Fri
and so on
if a1= 5000 & b1=Wed
how can I return 11:00
I have tried index and match =index(a:a,match(a1&b1,b:b&e:e,0))
View 9 Replies
View Related
Jan 4, 2010
I have a workbook file containing several sheets, is it possible to pull data from another sheet or workbook with multiple column criteria.
For example :
i want to filled a cell in Sheet B from Luas_Tanam column in sheet A, i'm thinking a database query like this :
--select from sheet "A" where column "estate" = "BSRE" or column "Divisi" = "Div 01" or column "No_Block" = "J17" or column "Tahun_Tanam" = "2008"--
It goes like =DGET() functions, but i can't get it work, maybe any other solutions?? i've attached example of the workbook, sory for the bad "ENGLISH" question.
View 4 Replies
View Related
Feb 12, 2009
i am trying to use VBA to query a access database that i have i want to be able to pull the information that matchs either textbox4 or 5 i am using the code below but i am getting global errors.
Private Sub CommandButton1_Click()
Dim custname As Variant
Dim Custnum As Variant
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
custname = Range("TextBox5").Text
Custnum = Range("TextBox4").Text
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"ODBC;DSN=Insolvency;Description=Insolvency;APP=Microsoft Office XP;DATABASE=Insolvency;Trusted_Connection=YES"), Destination:=Range("Listbox1"))
.CommandText = Array("SELECT * FROM POST WHERE Customer_Account_Name=" & custname & " AND Customer_Account_Number = '" & Custnum & "' ORDER BY Customer_Account_Number")
.Name = "Insolvency Post Query"..........................
View 9 Replies
View Related
Aug 12, 2006
I am trying to create a macro that will import data from an external database; however, I want to be able to filter the data using input from the end user. The code will work fine if I do not use a variable (i.e. I type "31" to replace the second instance of "Reply" below).
Dim Reply As Integer
Reply = InputBox("Week Number", " Find Week")
ActiveWorkbook. Sheets("RawData").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=DataWarehouse;Description=DataWarehouse;UID=DataWarehouse;PWD=;APP=Microsoft® Query;WSID=WILLIAM;DATABASE=tmd" _
, Destination:=Sheets("RawData"). Range("A1"))
.CommandText = Array( _
"SELECT vOEEDownTime. …, " & Chr(13) & "" & Chr(10) & "FROM tmd.dbo.vO" _
, "EEDownTime vOEEDownTime" & Chr(13) & "" & Chr(10) & "WHERE (vOEEDownTime.downtimecode Is Not Null) And (vOEEDownTime.weekbucket = Reply)")
.Name = "Query from DataWarehouse"
View 6 Replies
View Related
Sep 25, 2011
I want to web query an online database. One of the columns contains numbers 16 digits long. When Excel imports the query I get the number in exponential format and it replaces the last number with a zero.
Example: The original is 1002002660100027, after query ends up as 1.002E+15 and reformated as text I get 1002002660100020 (Last # changed to a "0")
Is there a way to prevent the query from replacing the last number with a zero when importing from a query? Or.. can I get the query to paste as text?
View 3 Replies
View Related
Feb 26, 2009
I have created an Excel sheet that retrieves data from a ODBC source. I have created a macro using macro recorder to refresh the data by re-connecting to the database. However, the connection requires a password prompt and when the macro is run, you are still required to enter the password.
Is there anyway to make the macro so that the password is automatically entered and the user will just have to press a button to fully run the query update?
View 2 Replies
View Related
May 28, 2014
Is it possible to use cell references to define parameters in an SQL query to an MS Access database?
I assumed it was similar to using SQL but I'm getting an error in excel.
Here is my query: .....
The error I get in excel is: "Invalid character value for cast specification" and it wont let me specify a cell.
View 6 Replies
View Related
Aug 24, 2009
I have created a query in an Access database which returns multiple results. I need to be able to run this query within Excel, but only showing the total of the results in a single cell.
I also need to run it multiple times on the same sheet using different dates. The Access query asks for a date each time it's run
I have only found ways to retrieve the entire results of the query into Excel based on the settings within the query.
View 9 Replies
View Related
Feb 1, 2007
I have a database that has outgrown excel (over 77,000 rows now) so i now have it in Access. I want to replicate the following situation I used to have using lookups in excel with a query to the Access database: Paste a list of identifiers into an excel sheet. Values corresponding to the list are returned from the database in adjoining columns. The list can be from 10 to 300 cells long an returns data in 14 columns. I have had a go with the Import external data wizard which generates a query but have not been able to work out how to base the query on a list of cells in excel and have the query return values for each of the identifiers in the list.
View 2 Replies
View Related
Nov 17, 2009
Is it possible to set parameters on a query but use a wildcard to return all instances? I have a query that I want to be able to set multiple parameters on but give the user the ability to select as many or as few parameters as they want to see. 2 of the parameters are number fields and 2 are text fields with no spaces.
View 4 Replies
View Related
Sep 6, 2008
I have a csv file on another drive on the network that i need to query. I believe that ms query would be the best way. I know that a DSN needs to be setup but this macro will be used by various users who wont know how to do that. thus I would like to create one via VBA every time the task needs to be run.
I haven't a clue how to do this and i need it to be explained to me in general terms with words of one syllable!
View 9 Replies
View Related
Apr 19, 2006
I have been using the following formula to return a value where a % is used, is there anyway i can make the sum shorter.
=SUMIF(Q10,'Price Calculator'!$A$5,'Price Calculator'!B5)+SUMIF(Q10,'Price Calculator'!$A$6,'Price Calculator'!B6)+SUMIF(Q10,'Price Calculator'!$A$7,'Price Calculator'!B7)+SUMIF(Q10,'Price Calculator'!$A$8,'Price Calculator'!B8)+SUMIF(Q10,'Price Calculator'!$A$9,'Price Calculator'!B9)+SUMIF(Q10,'Price Calculator'!$A$10,'Price Calculator'!B10)+SUMIF(Q10,'Price Calculator'!$A$11,'Price Calculator'!B11)+SUMIF(Q10,'Price Calculator'!$A$12,'Price Calculator'!B12)+SUMIF(Q10,'Price Calculator'!$A$13,'Price Calculator'!B13)+SUMIF(Q10,'Price Calculator'!$A$14,'Price Calculator'!B14)+SUMIF(Q10,'Price Calculator'!$A$15,'Price Calculator'!B15)+SUMIF(Q10,'Price Calculator'!$A$16,'Price Calculator'!B16)+SUMIF(Q10,'Price Calculator'!$A$17,'Price Calculator'!B17)+SUMIF(Q10,'Price Calculator'!$A$18,'Price Calculator'!B18)+SUMIF(Q10,'Price Calculator'!$A$19,'Price Calculator'!B19)+SUMIF(Q10,'Price Calculator'!$A$20,'Price Calculator'!B20)+SUMIF(Q10,'Price Calculator'!$A$21,'Price Calculator'!$B$21)
Seems like a Pain to be using something this big, just cant seem to get it to work when i try to shorten it
View 2 Replies
View Related
Jul 8, 2014
Say I have a certain range in excel from A1:C10. All of these cells contain one of three strings: Math, English, or Reading.
Given an input of ONE of these three (for example, a user can select "Reading"), the program should output ALL the row&column numbers of each occurrence of "Reading" in the range. Ideally, this would appear in a column.
Consider the following image that contains a sample range:
Screen Shot 2014-07-08 at 12.26.15 PM.png
If "English" is the input, the output should be (in another column)
A1
A7
B3
C2
C3
View 5 Replies
View Related
Dec 19, 2006
The actual link from a list on the left side of that web page is "Printable List".
I can't work out why all other web pages work fine with;
Get External Data/Web Query, but this particular web page won't work.
Sub Test_A()
Sheets("test1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://acttab.com.au/interbet/racing?type=venues", Destination:= _
Range("A3"))
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End With
End Sub
View 3 Replies
View Related
Aug 20, 2009
I am querying a database in Microsoft Query and I have it set to pull in jobs that match a customers code in cell A1. I would like it so that if cell A1 is blank, it pulls in jobs for every customer.
View 3 Replies
View Related
Sep 12, 2013
I am trying to run a prestored query in a Access database and popuate the result into a Recordset --- through Excel. So far, I have managed to accomplish that using the code below. However, now I need to update some records in the recordset. The code below does not allow me to do so.
The following message prompted when the code tried to update the record: Run-time error '3251' Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.
This is written for other users who only knows how to create a query in Access. And the users prefer not to import the query results to spreadsheet.
*Someone suggested use Recordset.Open however, that seems to work only with SQL statement but not prestored Queries.
Code:
Sub RunExistingQuery()
'Execute prestored queries in Access
Dim Con As ADODB.Connection
[Code].....
View 2 Replies
View Related
Jun 1, 2008
I am trying to query a names sheet where each row may contain more than one occurence of a member ID. There are no duplicate rows ( records), because the dates are different for all rows.
1. I want to retrieve all of the rows from the names sheet that match a unique member ID. So far I only get one row.
2. And if mistype the number, it gives me a wrong record .I would like to get an error message that if I don't get a match, that it appears in the somewhere like dialog box or even entry in one of the cells that no name exits.
View 4 Replies
View Related
Mar 31, 2004
I am currently trying to create a database of products for my company. For each product I would like to include an image associated with it. I then want to have on another sheet a place where the user will click an error and be able to cycle through the products. As tehy cycle the associated image will pop up.
What I need to understand is after importing the image into excel, how do I associate that image to a cell so I can reference it in another sheet of the database. I am not concerned with how large the database will get, my pictures are quite small.
View 4 Replies
View Related
Aug 6, 2013
Trying to use Excel Data List to create a database style report. IE. Originally blank sheet, which is only populated by data containing data matching "filters" input into cells ( say A1 & A2 )
I.e. A1 = Delivery week to be filtered by, and B1 Manufacturer Name
So if I type week "1" into A1 & Manufacturer "Microsoft" into A2, it will show a table only containing data Microsoft, Week 1, and associated data for those lines across the screen.
Week 1
Microsoft
PO number : Date Ordered: Address 1, 2 3 etc....
0011 01/01/13 Somewhere
0015 02/01/13 Anywhere
0213 05/01/13 Nowhere
I know this is much easier with a database, however my manager insists a database cannot be used, and it must be in a spreadsheet format !
View 3 Replies
View Related
Oct 17, 2013
I've used a countifs, but I'm having trouble doing a sum in a similar way. I have 2 databases and I will try to explain below. I need the to sum the values of database 1 if the second database is >= 20. So the value I would expect on this example would be 900. I would also like to be able to highlight which ones are elliminated. Such as coloring the text red.
Database 1
Eric 100
Jenny 200
Gina 300
Doug 400
Database 2
Eric 18
Jenny 20
Gina 34
Doug 55
View 5 Replies
View Related
Jun 3, 2006
I have a workbook with a database of 15 different products. We receive information with current prices for each of the 15 products on a weekly basis. This info comes in one single worksheet. I have created a different file with one worksheet for each product to track price behavior over time. I need to update these database everytime I get a new report. What I was trying to do is to develop a Macro to copy the data from a "Master" worksheet that includes all 15 products info to the respective worksheet for each product. Information is sorted in columns having the most recent date in the lowest column. I would need the Macro to copy the new data below the last price for each product. I would copy the data into the "MAster" worksheet, then run the Macro who would copy each row and paste it in its respective worksheet in the row rightafter the previous one.
View 4 Replies
View Related
Oct 19, 2012
I created a slick little excel sheet with the data coming in automatically via Access query. It has been working fine for months. Now all of the sudden there are a bunch of cells with missing data. The weird part is it's not as if whole columns are missing data, more like 90% missing. When I go to Access and run the query all cells are populated as the should be. There have been no changes to the query at all during this time.
btw...I am running Office 2010
View 2 Replies
View Related
May 31, 2014
A web query I am trying to use to bring an online data table into my worksheet is broken. Now, instead of returning the data table nicely into my worksheet, it imports the code of the webpage, instead, and turns my worksheet into a mess.
The query used to work but there was recently an "upgrade" to the program that populates the web table and the query no longer works and just returns the code for the page, instead. I can see the html code for the table in all of the code it returns but I really need the table to import cleanly into excel.
I can't talk to the people who changed the web program.
View 3 Replies
View Related
Oct 12, 2013
I have spreadsheets supplied by clubs to add data to a database. I am not a spreadsheet user,
Today I have a spreadsheet with the columns A to M repeated in the width of the spreadsheet.
How do I reduce that to one display?
View 7 Replies
View Related
Jan 15, 2010
I am trying to use an excel vba program to get data from a database and then use this data in my program. But i have no clue about where to start.
View 9 Replies
View Related
Jul 9, 2014
An external data web query points to a web site that offers a foreign exchange rate calculator. In my browser, I selected the specific currency pair I need and used the resulting url in the web query. The "New Web Query" pane resolves the url correctly and allows me to select the table data I want (the little yellow arrow turns to a green check mark). However, when I hit "Import" and select the target cell, the only data returned is the parameters from the url and an error msg (This web query returned no data...). How do I get the query to pass the parameters to the website correctly?
View 3 Replies
View Related
Nov 26, 2012
I have an MS Access query that contains a parameter. The parameter is a date field, and I have configured that in the Access query. If I run the query within the MS Access user interface, it prompts me for the paramater value as expected, and runs just fine. However, I want to connect to this query from within Excel as a data source.
I have created a connection to the Access file using ODBC from within Excel. In the MS Query window, I am merely selecting all of the fields resident in the MS Access query, and returning all values. In other words, there is no selection criteria in the MS Query. I have done this many times with Access queries that DO NOT contain a parameter, and everything works fine. However, in this instance, I need to pass a parameter through to MS Access in order for the query to run. At the moment, I get the "Too Few Paramaters...1 expected" error message. This makes sense, because I haven't figured out how to pass the paramater to MS Access.
Is there a way to structure this that does not involve VB code? If so, I'd love to know how. I have tried creating parameters in MS-Query with the same name, but although I get the prompt it doesn't connect with the Access query as the source for the parameter value.
If the solution requires using code, I'm good with VB Code in Excel...is there VB for Excel code that could make this happen?
Failing that, I guess there must be (I've seen a few in my search thus far) Access VB Code that can make this work. I'm very rusty using VB with Access, so this is my least favored solution. However, if this is the only option, keep in mind that I need to pass the paramater ultimately from a user who will initiate the process using Excel.
View 3 Replies
View Related