I have a combo box in a form that uses a query to get the row source (lookup list). I am trying to set the default value to blank but nothing seems to work. It still populates with the first row of the query result. I am thinking it may be because there is no blank value in the list.
Here are the properties I have currently:
Limit to list - No
Allow Value List Edits - Yes
Inherit Value List - No
Show only row source values - No
Default Value ""
Any help is appreciated
Related
I need to run the report, without selecting anything, with parameter field blank, and be able to view all the data.
the problem is that it necessarily asks me to enter a value (all or multi values).
Who can help me?
If you make sure that you do the following...
Set the parameter to "Allow blank value" and/or "Allow null value" depending on what datatype it is.
Set the default value to Blank (="") if applicable
If you have a list of available values set, make sure the default value is included.
The following example uses sample data from sample database and contains just a list of company names and their ID's.
The main dataset query filters the data based on 2 parameters (one is text the other id numeric to show different scenarios)
This is the dataset query
SELECT CustomerID, CompanyName
FROM [AdventureWorksLT2019].[SalesLT].[Customer2]
WHERE CompanyName LIKE '%' + #pSearch + '%'
and CustomerID > ISNULL(#pID, 0)
ORDER by CompanyName
The report design looks like this with 2 parameters defined
The first parameter is text and has "Allow blanks values" checked, the Default value is set to an expression =""
The second parameter is an integer, This time we have set "Allow null value" on but we have not set a default value.
Note: Neither parameter has any available values set...
When the report is run I get the following results without pressing anything.
Only if I manually set any of the parameters do I need to press View Report, but when the report first runs, there is no need to click anything.
If the above does not help, then show how the parameter(s) are setup up, what types they are, what the available values are and what the default values are.
In a form, I am displaying rows of data in the detail section.
Around 5% of the rows might actually have a float value in one column that I need to be displayed as a combobox. The column in question results from a left join, so it may have a float, or it may be null with no existing record behind it. I don't want to have 100000 rows added to a table just to show a zero in the combobox on the outside chance that a user actually displays that particular record. Yes, I can add the rows, then delete them later, but that seems stupid. For the life of me, I cannot figure out how to get the combobox to default to a zero for each row, and still be selectable. Basically for each row, show the value if there is one, zero otherwise, and let the user select a new value if they want.
The VBA side is easy. I can totally create the row if a non-zero value is selected, and delete the row if the user changes it to 0. Ideal would be to bind a combobox to NZ(myField,0), or something similar. When I tried that, the combobox was not selectable.
Right now my combobox is selectable, allows the users to change the value, but shows a blank, not zero if the column is null.
The SQL the form is bound to:
SELECT dbo.PersonClasses.ClassID, dbo.ClassDates.ClassDate, dbo.PersonClassHours.ClassHours
FROM dbo.PersonClasses
INNER JOIN dbo.ClassDates ON dbo.PersonClasses.ClassID = dbo.ClassDates.ClassID
LEFT OUTER JOIN dbo.PersonClassHours ON dbo.People.PersonID = dbo.PersonClassHours.PersonID AND dbo.ClassDates.ClassID = dbo.PersonClassHours.ClassID AND dbo.ClassDates.ClassDate = dbo.PersonClassHours.ClassDate
I am looking to represent ClassHours as a Combobox for each record on the form with valid selections being 0,.5,1,1.5,2,2.5. To keep it simple for the users, I want 0 to be preselected. This is how it looks now:
You could set the Format property of the combobox to
#;\0
This will display a zero if the field value is Null. Otherwise the actual value.
Other properties which will also need to be set are the Row Source Type to Value List and Row Source to 0;0.5;1;1.5;2;2.5
Using a function, such as Nz(), in your query to change the value of the field, actually creates a new field, which is read-only.
In your case you need the field to be updateable, so one of your options is to play around with the Format propery, or Conditional Formatting.
In MS Access in a field, if I click into the field, it places a 0 there as a default. I tried setting the default value to null but that didn't work.
The problem is that if I click in the middle of the field, the cursor is on the left of the 0 (see picture attached). Then I, or more specifically my client, has to click again or arrow over to delete that zero and type the number. Is there a way to have it just have a cursor with no value like a text field?
Tab over and it highlights everything no problem. But when I click into an empty field, I want it to be empty, not 0, so I can type in my number without having to delete anything. Any help on this?
unwanted zero
You can set almost all (number) fields to be NULL by default. You can set that in the table and in the form. If you set it in the table and create a form based on that table then the definition will be the same in the form.
Only very few fields, like indexed fields with no duplicates, don't allow NULL.
And you can set the default value in the table and the form.
Instead of changing to Null in Table change this in the Form. Property sheet select data tab, find default value and set as Null.
It's been awhile since i've worked in VBA. I have a bound form. It has two drop down lists. One list is bound the other not (the first ddl is a list of values. The second gets refreshed when the first one changes, using the value of the first to create a query for the second. That value is used as a fk in the table the form is bound too).
Anyway, when the form is first run and uses the default value for ddl 1, if the second combobox is empty, and I try to get the value, it's null, which is what you would expect. But, I have code that runs when ddl1's value changes, to requery ddl2. When it requeries, if the list is empty, and I do combobox1.value, instead of being null, the value is 1. This is confusing, because, since the list is empty, I would think it should be null. What's going on here? Here is what I have:
Combo1 is bound to a table
Combo 2 uses this query:
SELECT tbl_office.id, tbl_office.office_name
FROM tbl_office
WHERE (((tbl_office.otherTable_id)=[Forms]![dlg_addDivision].[Combo1]));
On Combo1 afterUpdate event:
me.Combo2.requery
So, after combo1 afterUpdate, the above sql gets called. If this produces an empty dataset, and I try to get the value of combo2, even though the list is empty, the value says it's 1
thanks
The requery requeries the List - not the value. The value stays whatever it is/was before. Its not a bug - its a feature ;-)
If you page through datasets that are already filled you wouldn't want them to be changed without user interaction. The List is just a helper for dataEntry (and validation - if you check "only listitems allowed") - but it has nothing to do with your dataset.
By setting the value to your first Entry like you proposed: Me.Combo2.Value = Me.Combo2.ItemData(0) you change the dataset intentionally. And that is how it is supposed to happen. Not via changing the list.
I have a report which returns list of product names and other product specs. This report currently has different search options. My users now also want to be able to search by product number by putting in multiple product numbers.
How can I add a filter by product number which is an optional multi-value textbox?
I have tried to add a multi-value textbox. The report doesn't seem to work when no values are entered. If I put one or more product number in the text box, it seems to work fine. Is there a way I can tell the report doesn't filter on the Null value parameters? Or any other idea to work with optional multi-value parameters?
Here is the setting for my multi-value textbox
Name = ProductNumber
Prompt = Product Number
Data Type = Text
Allow Blank Value (checked)
Allow Null value (not checked)
Allow Multiple Values (checked)
Here is the data set filter
Expression = [ProductNumber]
Operator = In
Value = [#ProductNumber]
Thanks
TL
I think you should trick the dataset filter by:
Expression should check to see if the parameter is blank and if so give expression a 1 else the field.
Value should do the same check and if parameter is blank set value to 1 else set it to the parameter.
But keep your operator.
Alternatively you could do this similarly in the SQL and with more flexibility and performance.
So as you've seen in your own testing, at least one value must be selected with multi-value parameters. You can't set Allow null value to true at design time and if you run a report without selecting any values it will throw an error message.
So you can't really have a report where users can run it with no values selected.
Taking a step back, what you're trying to achieve when ignoring the parameter is to include all Product Numbers by default. So why don't you set the parameter to have a default value of all Product Numbers selected? That way, users can just ignore and leave them all ticked if they don't want to filter by Product Numbers. Seems like a good workaround to me.
To do this, set the default value for the parameter using the same dataset that populates it:
All Product Numbers are now selected and users only need to take action if they want a subset of these returned.