Embarrassingly simple question but I can't work it out or find the answer via google.
Got something like this with two colums
But when selected it only displays one column, making the information much harder to read/ understand.
Tried changing properties in property sheet (such as column number) but to no apparent effect.
It depends to a certain extent on what you are doing, often something like this suits:
SELECT Id, Surname & ", " & Forename from Table
In other words, the bound column is a unique ID and the selection column includes both the surname and forename in a single column.
EDIT based on additional information:
SELECT [Contact].[CID], [Contact].[Csname] & ", " & [Contact].[Cfname]
FROM [Contact] ORDER BY [CID], [Csname], [Cfname];
Since my first column is used to group items in the second it didn't look nice to just separate them using
SELECT ID, [Type] & ": " & [Title] AS BothValues
as suggested. With a lot of items the dropdown looks confusing like in this example.
I found out that Access seems to display the first (technically) visible column in the combobox after a selection has been made. Therefore I ended up using
SELECT ID, [Type] & ": " & [Title] AS BothValues, Type, Title
and setting the width of the second column to the smallest possible, de facto invisible value (0";0.007";1",1"). Don't forget to raise the column count (4). Now the dropdown appears grouped, but I still get both information after the selection.
You can also use a visual workaround for this Access limitation, using a text box at the right of the combobox, and setting the textbox value equal to the third column of the combobox.
If the combobox is based on
SELECT [Contact].[CID], [Contact].[Csname], [Contact].[Cfname]
FROM [Contact] ORDER BY [CID], [Csname], [Cfname];
Set column width equal to 0cm;5cm;6cm (or whatever you may need) and combobox width equal to the second column (5cm).
Then create a new text box at the right of the combobox, without any space in between, set its width equal to the third column (6cm) and set textbox controlsource equal to:
=[combobox_name].[Column](2)
Textbox will not be modifiable by the user since it is associated to a control source.
Related
I originally had my combobox cbSortOrder defined in the form as a fixed Value List. I am now attempting to set this in VBA code, using an array. I have tried with a variant and string array but do not think my issue is connected with that but is something to do with the combobox definition.
When attempting to set these values in a With statement, I get the Object Doesn't Support Method error.
I have attached screenprints of the actual error and properties of my combobox.
Unfortunately, you cannot use collections as row source in Access. A Row Source Type of Value List refers to a comma (or semicolon) separated text (depends on the list separator setting in Windows).
If you don't want to use such a value list, use a Row Source Type of Table/Query and specify a table or query name. You can also insert a SELECT statement directly into this field.
This also means, that you must store the entries in a table for this Row Source Type. You can also use a local table instead of a table in the back-end.
Also, the ComboBox has no List property. Use the RowSource property instead. In the code behind of the form you can omit the Forms("formName") part.
With cbSortOrder
.RowSourceType = "Table/Query"
.RowSource = "SELECT Id, Description FROM tlkpSortOrder ORDER BY Description"
End With
or
With cbSortOrder
.ColumnCount = 2 ' If you have and id and a text
.ColumnWidths = "0" ' Hides the Id column
.RowSourceType = "Value List"
.RowSource = "1,Ascending,2,Descending,3,Undefined"
End With
See also: ComboBox.RowSourceType property (Access)
I am new to SSRS.
In report, I have One table layout result where its first row (there is a bug in total) and last row is having total of all the fields. (Like shown in below image)
Given 「Total」 in first row, which I want to remove from the Report simply. I have its source file and I tried already so many ways but I am not getting its solution.
Edited
Design View of the same is here
Row Groups Panel is looking like:
Group Properties:
Expression 1(top left most):
=Iif(Fields!LineCaption.Value="","TOTAL", Fields!DispOrder.Value & ". " & Fields!LineName.Value)
Expression 2(below of top left):
=Iif(Fields!LineCaption.Value=""," ", Fields!AddupInfo.Value)+ " "
Thank you to All Commentators for commenting and giving your precious time in my problem with suggestions.
But I have found my own way solution.
By creating condition on Row_Group Visibility option while it loads the data from server.
As「Total」field was getting calculated in Row_Group only. So in Visibility option, I checked for first Row that "If first row is not Line_Name(My field name) then Hide that Row".
Maybe this is not the accurate answer but this was the only option for me to add.
You can do it via the context menu in the matrix view, not in the "Row Group" are:
Problem:
I'm trying to make it so when a numerical field is filled in with a certain ID it fills in the other fields accordingly to what the first field was filled with. So if a person were to type in their ID it would populate it with their name accordingly.
Example:
But upon ID/numerical change I want it to do something like this:
Prior knowledge that may or may not help:
-I know this is possible with combo boxes but having a combo box with 2k-8k entries seems absurd
-I don't really think subform is optimal for this situation
-I think you can do this with "=DLookup" but I don't exactly understand how to pull it off
Please and thanks for any help. All is appreciated greatly!
Some built-in Access mechanisms:
Search field in the Navigation bar of the form.
Find feature (Ctrl-F).
Alternatively, with VBA you can use your own UI design and have more control:
Obtain the desired ID from the UI in whatever way you like - a textbox, a button and a popup, etc. Don't use a textbox that is bound to the actual ID field (ID fields should be read-only and you shouldn't use an edit field for a search field - keep them separate).
In VBA, obtain the ID that user searched for and then jump to that record using code like this:
Me.RecordsetClone.FindFirst "StudentID = " & studentID
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
You don't need VBA for this. Simply add the Student ID textbox value as a parameter the form's query and let it filter the results according the ID provided.
The query should be something like this:
PARAMETERS [Forms]![YourMainForm]![YourIdTextBoxName] Long;
SELECT *
FROM YourTableName
WHERE ((([Student ID])=[Forms]![YourMainForm]![YourIdTextBoxName]));
When you add a new ID, requery the form to see the results.
Me.Requery
Access 2010 here.
Ok, Dlookups appear behave different based on where they are used. I have this Dlookup
inside a ClockNo_AferUpdate() subroutine that works well on new form entries to change a label's caption to what is found in the "Employees" DB under "EmployeeName" field based on the entered "ClockNo" in a ClockNo combo-box:
Me.LabelName1.Caption = DLookup("[EmployeeName]", "Employees", "[ClockNo] =" & Forms![InspectionEntryForm]!ClockNo)
The Employees database has four fields: AutoNumber-type "ID," Number-type "ClockNo," Text-type "Shift," and Text-type "EmployeeName."
Re-EDIT:
The RowSource for the ClockNo combo box as it sources from the Employees database:
SELECT DISTINCTROW [ClockNo], [EmployeeName] FROM [Employees] ORDER BY [ClockNo];
END Re-EDIT
What I am looking for is the same functionality in Form_Current() so browsing through older entries preserves the Label's caption based on the entered ClockNo. Unfortunately, simply re-using the above Dlookup gives a "Run-time error '3075': Syntax error (missing operator) in query expression '[ClockNo] ='."
Attaching the Dlookup as a control source to a text box does work O.K, but labels seem to be the best use here. I have mucked about with the Criteria section of the Dloopkup for some time without any real success.
End goal is to have a simple label next to a combo box that displays the employee's name based on their current and past ClockNo entries. The name is stored in a separate Employees database alongside their clock number and their shift.
This should be quite simple as both the ClockNo entry and the Label operate on the same form with the same database. Thanks for your input!
You have a combo box named ClockNo with this as its Row Source:
SELECT DISTINCTROW [ClockNo], [EmployeeName]
FROM [Employees]
ORDER BY [ClockNo];
I'm not sure why you want DISTINCTROW there. I would have suspected DISTINCT to be more appropriate. But I don't think it matters.
The important point is that the combo already includes [EmployeeName], so you shouldn't need to use DLookup to fetch [EmployeeName] again. Simply read the value from the second column of the combo's selected row.
Imagine your form includes a text box named txtEmployeeName. In the form's current event, you could do this:
Me.txtEmployeeName = Me.ClockNo.Column(1)
Notice the column index numbers start with 0, so the second column is .Column(1).
And you could do the same thing in the combo's After Update event.
Finally, you wanted to change a label's .Caption, but I showed you how to change a text box's .Value. If you can't make this technique work with the label, just use a text box instead. You can set the text box's Enabled property to No and adjust its other properties so that it is visually indistinguishable from a label.
Another approach could be simpler still. If you want to keep [ClockNo] as the combo's bound value, but are willing to display [EmployeeName] as the combo's selected value, you can set the width of the first column ([ClockNo]) to zero. You would still see both [ClockNo] and [EmployeeName] in the dropdown. If this is acceptable, you wouldn't need to bother with a label or text box.
I have a DBLookupComboBox that is wired to a database query. That part is working fine. When I run the program the DBLookupComboBox is populated with the results of the query. I'd like to to see the DBLookupComboBox populated with the first item "Please Select" when the program first runs or when a new item action is initiated. (See below image)
Also, if I'm loading a previously saved database record that had selected Index 2 "Quick Elimination" how would I get the DBLookupComboBox to display that selected entry?
Yes, "Please Select" is index 0 and it is retreived as part of the query.
You could try this (I know you've probably solved it by now, as you asked over 2 years ago), but in case anyone else was interested...
dbluLookup.KeyValue := dbluLookup.ListSource.DataSet.FieldByName(dbluLookup.KeyField).Value;
That simply sets KeyValue to the first record in the ListSource dataset, which should be the row 'Please Select'.
My guess would be that the value of the underlying table field is NULL rather than zero, which tells the DBComboBox that no value has yet been selected and it displays accordingly.
If the value in the table were zero, I thinkg the text in the edit field of the combo would be selected to indicate that, but I may recall this incorrectly.
Anyway, just check for Field1.IsNull (or IsEmpty) and then set it to zero. It does mean that you can no longer distinguish between an "unknown value" (NULL) and "no selected value" (zero), unless you prevent the zero value from making it back into the table...
One way of doing this would be to add 'Please select' to the underlying table from which you are selecting, where the key to this tuple would be 0. Then when you display the combobox and the value of the connected field is 0, 'Please select' would be displayed. Of course, you have to make sure that this value is never selected!
The DBLookupComboBox displays by default the ListField(s) whose KeyField in the ListSource matches the DataField in the DataSource. So, to ensure to display some value for the DataField being NULL, you have to provide a KeyField of NULL in the ListSource. But one could imagine not wanting a NULL value in the underlaying table associated to the ListSource.
One way to circumvent this is to add the NULL value to the dataset behind the ListSource with a UNION SELECT. That should work just fine, since that dataset does not have to be editable.
Now, to assure this special dataset is only available when you are adding a new record to the dataset associated to the DataSource, manage the query for ListSource.DataSet in DataSource.OnStateChange. When DataSource.State = dsInsert, then update ListSource.DataSet.
Modification for Steve Childs answer in TwwDBLookupCombo, InfoPower component
cboFilterTravel1.LookupValue := cboFilterTravel1.LookupTable.FieldByName(cboFilterTravel1.LookupField).Value;
Thanks Steve It's works for me