i have a huge sql query that is attached to the rowsource of a listbox.
the SQL statement seen here:
ms-access: select from another query
actually returns the correct information if that information is under 2 records.
however if it returns more than 2 records it still populates the listbox but it populates it with null values. when i right click on one of the values and press COPY, it gives me this message:
"there isnt enough memory to retrieve data for the list box"
But does the query work if it is run separately? And is the number of columns in the query the same number of columns as you've specified in the listbox Column Count property?
In your reply you state that you have to combine it? Why? Basic trouble shooting is to see if you can run the query separate from the lixtbox.
Related
as the title suggests I am writing SQL out of excel vba to query Forms contents out of a MS-Access db. The SQL works fine however, the fields where combo boxes are, the SQL returns their index instead of the text field.
I spent some time googling this but most of the results are asking how to display on the form in the combo box, I am just trying to return the text display form the combo box with my SQL.
I will go ahead and say the person who designed this did a bad job, and the tables relating to these drops down have nothing in common(the tables are just a list of the drop down values and ID's).
My question is what is the best way to return this value? Can I join based off the drop down index?
This link should help you get started.
http://access.mvps.org/access/forms/frm0031.htm
Something like this, I presume...
Forms!Mainform.RecordSource
I am currently working on a project on MS-Access 2010 and I am struggling with a issue for hours. I would like to apply a filter on a SELECT/PIVOT statement. The result of that query is displayed in a ListBox.
The issue is that no results are displayed when the Combobox is set to Null. But when I select specific values in that Combobox it works perfectly.
The Cbbox filter is declared as a Parameter
My query WHERE clause looks like this :
WHERE (Jobs.fk_group=[Formulaires]![frm_MAIN]![lst_filterGroup] AND (fk_otherCritera='XXX'))
OR ((([Formulaires]![frm_MAIN]![lst_filterGroup]) Is Null) AND (fk_otherCritera='XXX'))
The query WORKS while I enter manually the value of the parameter (=when I enter an empty string, it displays all the records = what I want)
Idk if it is important, but also the listview that I use swap dynamically its recordsource (=it runs 2 differents queries), depending from another Cbbox
I checked the parameters values into my VBA code just before MyListview.Requery calls and IsNull(myCbboxReference) returns True and my other criteria is also OK.
I have no clue of what I did wrong, I need help :-(
Best regards, LR
I would recommend to use special value in combobox for displaying all records in main table and don't rely on comparing with Null values. Your query, probably, doesn't work because empty combobox returns "" , not Null.
Also be careful with queries based on references to controls/parameters. Access has a bug: if you apply filter on data in the form, based on query with such kind references, it stops read new values from controls/parameter during Requery. It appears at least for subforms in Datasheet mode. Workaround for this bug - using function instead of reference.
I need to create a query on the fly through VBA that get some strings from a table based on a set of criteria selected by the user . From the results of that first query I need to find the position of certain characters in the strings and only select the one that have the characters at a given position. This need to be done quickly as it then needs to be displayed in a combo box for the user to select before he runs a full other query.
So my question is what is the fastest/best way to do this ?
Should I put the result of the first query in a temporary table , analyze the strings from that table, delete the records that don't meet the selection and then run a query to display in the combo box from that table ?
Thank you
I have a query that will be populating a form and then the form will allow the data set to be edited. The issue I am having is that the query is pulling the last row that is normally used to add a new record. This results in having a row that looks shows all fields as blank, but leaves one field with "null".
I played around with the query and was able to find a workaround by selecting "distinct" records, problem is that when you select with distinct, you cannot edit the data set. Is there any other way around this?
I can upload an example of the database if needed.
Thanks!
edit: picture to show the issue: https://imgbomb.com/i/?rO1sp
I have created a query to calculate the sum of all of the profit values in a table, I tried to output this to a textbox on the main form of my database and I just the error #NAME?.
Has anyone tried this before and are there any major things I am missing?
We would need to see some code/design details to understand why your text box gets that #Name error.
Without those details, I'll just suggest you consider a DSum() expression, instead of a query, to load the text box. And DSum() is kind of like a SELECT query, but returns only a single value instead of a result set.
DSum("YourNumericField", "YourTable")
Examine the DSum online help topic for more details. You might find the optional Criteria parameter useful (like a WHERE clause in a SELECT statement) if you ever want to sum only a subset of rows from your table.
DSum("YourNumericField", "YourTable", "account_status = 'ACTIVE'")
If you have create query to calculate the sum called "querySum". On the form property sheet, make sure selection type you change to FORM, go to Data and select "querySum" as record source.
And then, click text box, go to the property sheet and choice Data > Control Source. So you can choice column from query to the text box.
Otherwise, if you want to use VBA. You can do like this
DSum("NumericField", "YourTable")
Or with condition
DSum("NumericField", "YourTable", "type = 'Payment'")