I would like to hide empty fields, not show a blank line. How can i do this?
Add a row to your details group to hold the potential list of values. Drop a single textbox field that displays a calculated field. The calculated field should be an expression similar to the below to display up to 4 sequential fields.
=Fields!ExampleField1.Value & IIF(Fields!ExampleField1.Value.ToString().Length >0,vbCrLf,"") &
Fields!ExampleField2.Value & IIF(Fields!ExampleField2.Value.ToString().Length >0,vbCrLf,"") &
Fields!ExampleField3.Value & IIF(Fields!ExampleField3.Value.ToString().Length >0,vbCrLf,"") &
Fields!ExampleField4.Value
Select the TableRow (not the individual cells) you want to make conditionally suppressed, then enter the conditional suppression formula into the Visibility - Hidden property expression on the Properties tab.
Related
Wonder if any of y'all can help me. I keep getting errors on this. Here's my table:
- tblCutting
- PartNumber (Primary Key Text Field)
- CuttingStep1 (Number)
- CuttingStep2 (Number)
- CuttingStep3 (Number)
I'm trying to use a combo box (cmbPartNumber1) to pick from PartNumber and then a text box fills in with the corresponding CuttingStep1. Here's are the various formulas I've tried underneath the textbox:
=DLookUp("CuttingStep1","tblCutting","cmbPartNumber1=" & [tblCutting]![PartNumber])
=DLookUp("CuttingStep1","tblCutting","[cmbPartNumber1]=" & [tblCutting]![PartNumber])
=DLookUp("CuttingStep1","tblCutting","cmbPartNumber1=" & [PartNumber])
=DLookUp("CuttingStep1","tblCutting","[tblCutting]![PartNumber]=" & [cmbPartNumber1])
=DLookUp("CuttingStep1","tblCutting","[PartNumber]=" & [cmbPartNumber1])
None of these have worked and I have no idea why. Any suggestions?
Or am I way off on how this is supposed to work?
Edit: added field types above.
Text values need to be delimited:
=DLookUp("CuttingStep1","tblCutting","PartNumber='" & [cmbPartNumber1] & "'")
Also, since your textboxes are using a calculated formula, they are "Unbound", therefore you need to update their contents yourself.
To handle this you'll need an event sub for the "Change" event of your ComboBox. Add the following code or similar, since I do not know the names of your Textboxes. Add to your Form Module:
Private Sub cmbPartNumber1_Change()
' Refresh (recalculate) values. textBox1,2,3 are names of your Textboxes that contain calculated values based on value of cmbPartNumber1.
textBox1.Refresh
textBox2.Refresh
TextBox3.Refresh
End Sub
I have a combobox on a form for selecting a specific shelf location. I also have a number of textboxes imitating a shelf location. I would like to use the result of my combo box selection to change the color of a matching textbox label, for example combobox selection is F14. Textbox label name is LabelF14. How do I code that for event afterupdate to select LabelF14 from the combobox result, F14?
Build control name by concatenating literal text and variable, like:
Me("Label" & Me.comboboxname)
If need to set multiple controls' BackColor at same time, can use a For Next loop. If there are say 15 controls with similar names like LabelF1, LabelF2, ... LabelF15:
For x = 1 to 15
Me("LabelF" & x).BackColor = IIf(Me("LabelF" & x).Name = "Label" & Me.comboboxname, vbGreen, vbWhite)
Next
Make sure BackStyle property is set to Normal, not Transparent.
Keep in mind that programmatically setting properties of a control will affect all instances of control.
If you colored textboxes instead labels, could probably use Conditional Formatting instead of VBA.
I'm new to Access so this might be a simple question.
I have a form in Access 2013. There is a subform displaying a table from an SQL server, like so.
Company Product
-----------------
CompanyA Product1
CompanyA Product2
CompanyB Product1
CompanyB Product2
Using ListIndex in a list box, I can display the index of any row I click on. For example if I click on the second row (CompanyA, Product2) the list box shows a ListIndex of 1. If I click on the third row the ListIndex is 2.
How do I get a list box to display the value of a column instead of the ListIndex?
What I am trying to do is that, when I click on a row in the subform, I'd like to display each column value for that row in its own list box.
However, I cannot seem to use ListIndex as a variable in a larger function. I've attempted the following:
Typing only the column name into the list box. Does not update the value if I click on a different row.
Column property does not update the value if I click on a different row.
Controls property gives an error.
Value property displays the correct row but only works for the first column.
Combo boxes circle back to the problem that I need to use ListIndex as a variable.
Is there a different property I should be using? Am I missing something in the properties I tried?
There seems to be a little confusion with terminology. Your List3 is a list box, not a subform.
The fields Company and Product look like text boxes, but if the first one has the control source =[List3].[ListIndex], and shows a text and not a number, it seems to be a listbox with height = one line.
I suggest using text boxes for Company and Product, with these control sources:
=[List3]
for the bound column. Alternatively, for consistency: =[List3].Column(0)
=[List3].Column(1)
for the second column.
These text boxes update themselves automatically when you click on an item in the listbox.
To get the value of a listbox, and if you allow multi-select, use the following example:
For Each varItem In Me.lstHierarchy.ItemsSelected ' Loop through the items selected (if multi-select allowed)
strPrint = ""
For i = 0 To iCols ' Loop thru each column in a row
strPrint = strPrint & "|" & Me.lstHierarchy.Column(i, varItem)
Next i
Debug.Print "Selected Value: " & strPrint ' Display the row; columns are delimited with '|'
Next
I cant seem to figure out how to reference a combo box value on a form in another textboxs sum iif function. The sample of what I am trying to do is below, with the reference to "TestCombo" the value I want to change based on who is selected. I tried using CHR(34) quotes, and I cant seem to figure it out.
SUM(iif([SaleStatus]= 'Pending' And [SalesAdvisor] = [TestCombo],1,0))
This same function works if I do the following
SUM(iif[SaleStatus]= 'Pending' And [SalesAdvisor] = 'TestAdvisor',1,0))
That led me to believe I needed quotes, which I expected, but that doesn't work either, such as the example below.
SUM(iif"[SalesStauts]= 'Pending' And [SalesAdvisor] = " & chr(39) & [TestCombo] & chr(39) & "",1,0))
Can somebody help me use the combo box as a dynamic reference to the sum iif?
Are you sure that your combo is equal to 'TestAdvisor'? It is quite common to have a numeric bound column and a text display. If you have more than one column in the combo, you will need to refer to the column property to get the text column. If you include the RecordSource for the combo in your question, it will be easy to see.
I'm having problems with a cascading combo box. Everything works fine with the combo boxes and the values get populated correctly.
Private Sub cmbAdjComp_AfterUpdate()
Me.cboAdjOff.RowSource = "SELECT AdjusterCompanyOffice.ID,
AdjusterCompanyOffice.Address1,
AdjusterCompanyOffice.Address2,
AdjusterCompanyOffice.Address3,
AdjusterCompanyOffice.Address4,
AdjusterCompanyOffice.Address5 FROM" & _
" AdjusterCompanyOffice WHERE
AdjusterCompanyOffice.AdjCompID = " & Me.cmbAdjComp.Column(1) & _
" ORDER BY AdjusterCompanyOffice.Address1"
Me.cboAdjOff = Me.cboAdjOff.ItemData(0)
End Sub
The secondary combo box has a row source query:
SELECT AdjusterCompanyOffice.ID, AdjusterCompanyOffice.Address1,
AdjusterCompanyOffice.Address2, AdjusterCompanyOffice.Address3,
AdjusterCompanyOffice.Address4, AdjusterCompanyOffice.Address5 FROM
AdjusterCompanyOffice ORDER BY AdjusterCompanyOffice.Address1;
Both comboboxes have the same controlsource.
Everything works fine and dandy moving between records and the boxes show the correct fields for each record.
When i use the first combo box, and then select the appropriate option in the second combo box, everything works great on the specific record.
However when I move to the next record, the values in the second combo box are all empty. If i close the form and reopen it, and avoid using the cascading combo boxes all the values are all correct when i move between records.
Somehow using the cascading combo boxes creates a conflict with the row source of the secondary combo box.
Hope that is clear! Have been rummaging around for an answer but cant find anything.
any help would be greatly appreciated.
Thanks
Noel
The reason why the combo box is blank when you navigate to the next record is because you have NotInList set to TRUE (which is what you want), but when you arrive on the record, the rowsource has been filtered to not include the value stored in the field the combo box is bound to. Thus, it's blank -- the value is there, but it can't be displayed, since it's not in the list.
To fix this, you need to clear the filter on the second combo box. To do that, in the OnCurrent event of your form, set the rowsource of the filtered combo box to be unfiltered:
Me!cboAdjOff.RowSource = "SELECT AdjusterCompanyOffice.ID, AdjusterCompanyOffice.Address1, AdjusterCompanyOffice.Address2, AdjusterCompanyOffice.Address3, AdjusterCompanyOffice.Address4, AdjusterCompanyOffice.Address5 FROM AdjusterCompanyOffice ORDER BY AdjusterCompanyOffice.Address1"
I usually handle this by creating two constants at the top of the form's module, one for the SELECT statement and one for the ORDER BY:
cstrRecordsourceSelect = "SELECT AdjusterCompanyOffice.ID, AdjusterCompanyOffice.Address1, AdjusterCompanyOffice.Address2, AdjusterCompanyOffice.Address3, AdjusterCompanyOffice.Address4, AdjusterCompanyOffice.Address5 FROM AdjusterCompanyOffice"
cstrRecordsourceOrderBy = "ORDER BY AdjusterCompanyOffice.Address1"
Then it's much easier to handle. In the OnCurrent it looks like this:
Me!cboAdjOff.RowSource = cstrRecordsourceSelect & " " & cstrRecordsourceSelect
...and in the AfterUpdate of your first combo box:
Me!cboAdjOff.RowSource = cstrRecordsourceSelect & _
"WHERE AdjusterCompanyOffice.AdjCompID = " & Me!cmbAdjComp.Column(1) & _
" " & cstrRecordsourceSelect
This makes the code easier to read, and it also makes it easier to alter the rowsource if you need to, since you have to edit only the constant.