Access - Excluding first column from lookup values - ms-access

I have this database and a field's lookup is set to comboBox with 'bound column' to 2 and 'column count' to 2.. My row source's first column is ID (AutoNumber), and my second column is Name(Text). When I go to Datasheet View and select a value it displays ID column value.
How to make it display a Name column value?

There are two basic ways to achieve this manually. This has to do with updating properties of the combo box. The particular properties are listed under Data or Format.
Return the ID as the first column, set the column count to 2, set the data bound to column 1, and define column widths with the first width = 0. Something like, 0";2" This way technically both columns display, but the first one has 0 width.
Or my preferance
Return the ID as the second column. Set the column count to 1 and bind the value to column 2. Doing this only the first column will display, but the 2nd column will be the value. The reason I prefer this method is that you can let Access determine the size of the drop-down column instead of defining it.

I just managed it in one way. In Design View, from dropdown list of your field (the one with lookup comboBox) select Lookup wizard.. Then go through the wizard, and that's it. However, I'm not sure how the wizard solves it.

Select the column1, column2, column1(again)
Set width = 0.01;.5;.5
column1 is not visible, but is the value you want in your field

Related

Brining row where column valus is null

I have a store procedure which brings the data as shown below . I'm new to SSRS reporting, I would like to show only those row where "email" column is null. How can i achieve it in SSRS ? As i mentioned I'm very new to this , any screenshot will help me a lot. Thank you for your time.
For this problem, you'll want to change the row visibility to hide rows with a value in that column. I assume you're using a table or matrix to layout this data. You'll want to right click on the row where your data fields are entered. Specifically, the grey box at the left of the row.
From there, you'll need to select the option to Show or hide based on an expression.
And finally, you'll need to enter an expression that finds the values in the email field. I'm not exactly sure what the field names are called but something like the following expression should do it.
= Not IsNothing(Fields!EmailField.Value)
This will check the field where you get the email value with a built-in function of IsNothing. Additionally, since you want fields that do not contain values, the Not keyword reverses the results. If the function evaluates to true and a value is present, the row will be hidden and vice versa.

How Can I use a ComboBox bound to a null record in a detail section?

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.

How to get bound column value in VBA -MS Access

I have a combo box in my form which I filled from another table role.
role has two columns : Id and Role
Given my table in Row Source and Bound Column value as 2 and column widths as 0cm;2cm
I can see my Role in combo box which is fine. What I need is
On Submit, I want to read the Id value in VBA for the Role selected. How to achieve this -- Resolved it by setting Bound Column value as 1
How to set Default Value as one of the Role -- Help to make this happen
I have to set similar case for my ListBox in same form
Since you have a multi-column combo box, both questions relate to the same combobox property : column
MyComboBox.Column(Index, Row)
Row is optional.
Use 0 to refer to the first column, 1 to refer to the second column,
and so on. Use 0 to refer to the first row, 1 to refer to the second
row, and so on.
Question 1: Suppose you bound your id to the second column. In the submit code, you can retrieve your id like this: myid = MyComboBox.Column(1)
Question 2: Suppose you want to assign role id = 3 and your id is bound to column 2. In the Load event of your form, do this : MyComboBox.Column(1) = 3

Retrieve column values of the selected row of a multicolumn Access listbox

How can I retrieve the value of specified column of the selected row in a multicolumn listbox?
I populate the listbox by setting the RowSource property with a SQL string. BoundColumn set to value 1.
I can retrieve the value of the bound column (of the selected row) by using ListBox.Value. But I also want the value of another column.
Use listboxControl.Column(intColumn,intRow). Both Column and Row are zero-based.
Just a little addition.
If you've only selected 1 row then the code below will select the value of a column (index of 4, but 5th column) for the selected row:
me.lstIssues.Column(4)
This saves having to use the ItemsSelected property.
Kristian
For multicolumn listbox extract data from any column of selected row by
listboxControl.List(listboxControl.ListIndex,col_num)
where col_num is required column ( 0 for first column)

MS Access Dropdown List/Combo Box

This should probably be pretty simple but my Google-Fu is as yet unable to find an answer. I simply want to create a dropdown list in Access so that upon selection I can perform some action based on the value of the selection. For instance, I have a list of people and I would like to populate the combo box so that their names appear in the list but the "value" is set to their ID (the primary key).
It sounds like you might be asking how to display something in the dropdown other than the ID while keeping the ID as the returned data from the dropdown. If that's the case set the Bound Column to the ID field (usually 1) and (assuming the name field is next) set the Column Count to be 2 and the Column Widths to be 0";1" or 0";[whatever width you need].
You will need to hook into the onchange event for the dropdown list.
and from MSDN
How have you set the properties for your combo box?
Perhaps you could try setting (assuming you are pulling data from Table1 with fields ID and Field1
Row Source: SELECT [Table1].[ID], [Table1].[Field1] FROM Table1;
Row Source Type: Table/Query
Bound Column: 1
Column Count: 2
Column Widths: 0", 1"
and then hook into the onchange event as Chris Ballance suggests. The value property of the combo box is ID; the text will be what is in Field1.
OK, I figured it out even though it was a bit counter-intuitive. An Access Combobox can have as many values as you want (instead of just one key on value). By default all of the values are are shown in the list so you need to hide certain columns by setting their widths to 0. That is done via the ColumnsWidths property in the property pane. ColumnWidths takes a comma separated list of values which corresponds to the order of the columns in the list. I hope this helps someone.