473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Recordset from Access to Excel based on a Query with combo box criteria

Hi there how r u .I would really appriciate ur concern regarding checking out this code.
its beind a command button and i am have a combo box selecing a query criteria and then pressing the button to take care recoredset from access to excel.
i have checked the code in any ways its working fine but when i use the combo box criteria
forms!formname!combobox
in the query the code breaks down at

rst.open a """""""""""gives me error one or two parameter values are not entered"""""""""""""""

AT BREAK POINT IN IMMEDIATE WINDOW WHEN U PUT UR MOUSE OVER COMBO IT DOES PASS THE VALUE BUT WHEN I COMES TO
rst.open a
error occurs

I have already tried
a = a + " HAVING (((tblndwpcsvw.CAT) = " & Me.Combo3 & "))"
instead of
a = a + " HAVING (((tblndwpcsvw.CAT) = [Forms]![tblndwpcsvw]![Combo3]))"

thankxxxxxxxxxxxxxx and have a nice day bbye

NOTE:Copied the SQL from query
NOTE:"""""""""""""""""the query involve a crosstab query thats why the explicit parameter is required""""""""""



Private Sub Command1_Click()


Dim cnn As ADODB.Connection

Set cnn = CurrentProject.Connection
Dim rst As New ADODB.Recordset
rst.ActiveConnection = cnn
Dim a As String

a = " PARAMETERS [forms]![tblndwpcsvw]![combo3] Text ( 255 );"

a = a + " SELECT tblndwpcsvw.CAT, [PROFILING Query].WK, [PROFILING Query].[2004], [PROFILING Query].[2005], [PROFILING Query].[2006]"

a = a + " FROM tblndwpcsvw INNER JOIN [PROFILING Query] ON tblndwpcsvw.PCS2 = [PROFILING Query].CAT"

a = a + " GROUP BY tblndwpcsvw.CAT, [PROFILING Query].WK, [PROFILING Query].[2004], [PROFILING Query].[2005], [PROFILING Query].[2006]"

a = a + " HAVING (((tblndwpcsvw.CAT) = [Forms]![tblndwpcsvw]![Combo3]))"

a = a + " ORDER BY tblndwpcsvw.CAT, [PROFILING Query].WK;"


rst.Open a

Dim xl As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet

Set xl = CreateObject("excel.application")

Set xlbook = GetObject("c:\abc.xls")

xl.Visible = True


xlbook.Windows(1).Visible = True

Set xlsheet = xlbook.Worksheets(1)

xlsheet.Range("b3").CopyFromRecordset rst


Set xl = Nothing
Set xlbook = Nothing
Set xlsheet = Nothing
rst.Close
Set rst = Nothing

End Sub
Jul 6 '07 #1
4 2491
JKing
1,206 Expert 1GB
Could you post the error number and description for the error you are receiving?
Jul 6 '07 #2
Thank you very much for checking out this code.please check below i am receiving this error in the msg box.
talk to u later take care and have a nice day
bbye



Run-time error '-2147217904(80040e10)':
No value given for one or more required parameters.
Jul 6 '07 #3
Hi JKING thank u very much i lost lots of time on this SQL but u helped me out by pointing me to work on the error number so i came across this sql and its working now
its passing the value in the immediate window
but now i am getting this error

"syntex error in parameter clause"

the sql i am using now

a = " PARAMETERS " & [Forms]![tblndwpcsvw]![Combo3] & " Text ( 255 )" + " SELECT tblndwpcsvw.CAT, [PROFILING Query].WK, [PROFILING Query].[2004], [PROFILING Query].[2005], [PROFILING Query].[2006]" + " FROM tblndwpcsvw INNER JOIN [PROFILING Query] ON tblndwpcsvw.PCS2 = [PROFILING Query].CAT" + " GROUP BY tblndwpcsvw.CAT, [PROFILING Query].WK, [PROFILING Query].[2004], [PROFILING Query].[2005], [PROFILING Query].[2006]" + " HAVING (((tblndwpcsvw.CAT) = " & Me.Combo3 & "))" + " ORDER BY tblndwpcsvw.CAT, [PROFILING Query].WK;"

rst.Open a
Jul 6 '07 #4
JKing
1,206 Expert 1GB
Have you tried running it with just this:

Expand|Select|Wrap|Line Numbers
  1. a = "SELECT tblndwpcsvw.CAT, [PROFILING Query].WK, [PROFILING Query].[2004], [PROFILING Query].[2005], [PROFILING Query].[2006]" + " FROM tblndwpcsvw INNER JOIN [PROFILING Query] ON tblndwpcsvw.PCS2 = [PROFILING Query].CAT" + " GROUP BY tblndwpcsvw.CAT, [PROFILING Query].WK, [PROFILING Query].[2004], [PROFILING Query].[2005], [PROFILING Query].[2006]" + " HAVING (((tblndwpcsvw.CAT) = " & Me.Combo3 & "))" + " ORDER BY tblndwpcsvw.CAT, [PROFILING Query].WK;"
  2.  
As you've said it is receiving the value from the combo box. I don't believe you need to specify the control as a parameter in the query. This should solve your error.

Another note without knowing exactly whats in your tables or queries or the purpose behind them I can't say this for certain but it does seem like this query string is unnecessarily long.
Would the following not produce the same results?
Expand|Select|Wrap|Line Numbers
  1. a = "SELECT [Profiling Query].CAT, [PROFILING Query].WK, [PROFILING Query].[2004], [PROFILING Query].[2005], [PROFILING Query].[2006]" + " FROM [Profiling Query] WHERE [Profiling Query].CAT = " & Me.Combo3 &  " ORDER BY [PROFILING Query].CAT, [PROFILING Query].WK;"
  2.  
Jul 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: HKM | last post by:
Hello, I have a query engine that builds the SQL Query to obtain the recordSet. Following is an Exmaple Query that my QueryBuilder outputted SELECT * FROM BookInfo WHERE BookName LIKE...
9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
3
by: dixie | last post by:
I have a form full of subforms which bring summary information onto the form from about 12 different tables. I am trying to get all of that summary information (mainly numbers) into 1 large table...
7
by: Jean | last post by:
Hello, I have a form that performs a search, according to criteria that a user enters into the text boxes. When the user clicks on „Search", a SQL string (say strSQL) is built up with the...
2
by: Lyn | last post by:
If I have a form where the RecordSource property is set to the name of a table, then on opening the SingleForm form I can cycle through all the records in the table one at a time via Next and...
10
by: LucaBrasi | last post by:
I am using a DAO recordset based on a table on the back end, and the table has almost 11,000 rows. Is there a way to 'filter' the table to use only the rows that meet my criteria ? I know I could...
1
by: Jaime Leivers | last post by:
Here's a median function in access that you can call in any query. You could change this to any excel function you wanted. Most people can find the windows help file that says how to call an excel...
2
by: JonC | last post by:
I have a database where the user selects recordsets via a form with 2 levels of nested subforms. The recordsets are filtered using a series of linked combo boxes and I would like to be able to...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.