List Box enable/disable one column - ms-access

Access 2007: Is it possible to enable/disable one column in a List Box on a form. For example: Say you have 2 columns A,B - If Me.A = title Then Me.B.Enabled = True Else Me.B.Enabled = False.
If so, where would it go? On Got Focus, On Click??
Thanks

I'm not sure what you mean by disable, but you can hide a column by adjusting the ColumnWidth.
So if you wanted to hide column2:
Me.MyListBox.ColumnWidths = (1 in;0;1 in)
And to hide column1:
Me.MyListBox.ColumnWidths = (0;1 in;1 in)

Related

Can I store the same option value for more than one toggle button in a control box?

I have a list of questions each with 4 possible answers that are displayed as toggle buttons on my form. What I want to do is if the user chooses either of the first two buttons, the Option Value stored is "1", if they choose either of the last two buttons, the Option Value stored should be "0". The option values must be different for each toggle button in a control group. Is there a way to recode the toggle buttons to store the desired response? (I work in psychology, thus the bait and switch of offering 4 choices to the user when really only two responses are recorded).
Here is what I have tried:
I tried thinking about a recode as jcarroll suggested, but this is a circular reference:
Private Sub Q1_Click()
If Me.Q1 = 1 Or 2 Then
Me.Q1 = 1
Else:
Me.Q1 = 0
End If
End Sub
I could recode into another variable but that is just as clunky as using a SQL statement on the data post-hoc, for instance:
NewVariable=Iif([Q1]=1,1,iif([Q1]=2,1,0)
Finally, I tried to code have both toggle buttons have the same Option Value (which causes both to look pressed if either is pressed) and recode the unpressed toggle button's back color. But while my code looks correct to me, this did not change the pressed color of the toggle button (which I think has to do with over riding toggle button design settings):
Private Sub Frame5_Click()
If Toggle8.Value = True Then
Toggle9.BackColor = &HFF00&
Else
Toggle9.BackColor = &H8000000F
End If
End Sub
I could not come up with any programming solutions on the form itself to solve this. The alternative is that I wrote a procedure to apply to the data after it is collected which will be stored as 1,2,3,4 to convert it to 0 or 1. This procedure also sums up the 1's. I have 50 variables/questions that will be passed through this procedure (as well as another like it that converts 3&4 to 1).
Public Function Recode1(ParamArray arg()) As Variant
Dim Size As Integer, skips As Integer, i As Integer, result As Variant
'Recodes first two toggle buttons as "1" for AQ assessment
Size = UBound(arg) + 1
For i = 0 To Size - 1
If IsNull(arg(i)) Or Not (IsNumeric(arg(i))) Or arg(i) = -99 Then
skips = skips + 1
Else
If arg(i) = 1 Or arg(i) = 2 Then
result = result + 1
Else:
result = result + 0
End If
End If
End sub

How to set textbox by value which get from each row of tablix?

If Datasource has 4 rows like these
___Item_____
AA
BB
CC
DD
If I make 10 textboxes
I need to input 4 value (AA,BB,CC and DD) to textboxes.
if some textbox isn't value, It will show (***)
like below .
1st row put to the first textbox.
2nd row put to the second textbox.
3rd row put to the third textbox.
4th row put to the fourth textbox.
and other put (***) because of Datasource has only 4 rows.
I mean I need to show free layout .I not mean horizontal tablix .
Because you wish to display the data in a fixed amount of textboxes and your dataset only has a single column, you shouldn't really try to fill the report dynamically. Instead of using an undefined datasource you could simply format the data and pass it as a list of parameters to the report.
ReportParameter[] reportParameters = new ReportParameter[10];
for (int i = 0; i < reportParameters.Length; i++)
{
reportParameters[i] = new ReportParameter(string.Format("pParam{0}", i),
(i < myDataSource.Count) ? myDataSource[i] : "***");
}
myViewer.LocalReport.SetParameters(reportParameters);
Then simply make sure you have parameters defined for the ones you are trying to display (e.g. pParam0 , pParam1, ... , pParam9) and add those in the wanted textboxes.

Creating a value in a control on a form

I need to create a value in a text box control upon triggering a certain event to allow me to then relink my forms to a different master/child link scheme. This value is to be used subsequently to create an if statement. For some strange reason, the value is generated and formatted correctly but regardless of what is in the text box, the If statement does not recognise this value and knows it only as blank. I tried numbers, letters but everything is the same.
In my example below, after updating the control (text box) 'txtDeviation' to the value of '1', for some strange reason is not recognised in as the value 1.
Private Sub cmdSkillsTracking_Click()
Form_frmValueChain01!frmValueChain02.SetFocus
Form_frmValueChain01.Pagina370.Visible = False
Form_frmValueChain01.Pagina371.Visible = True
If txtDeviation01 < 1 Then
Form_frmValueChain01.Form.frmValueChain07.LinkMasterFields = "txtMicroProcess01e"
Form_frmValueChain01.Form.frmValueChain07.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain17.LinkMasterFields = "txtSubProcessID"
Form_frmValueChain01.Form.frmValueChain17.LinkChildFields = "IDskillsmatrix"
Form_frmValueChain01.Form.frmValueChain16.LinkMasterFields = "txtSubProcessID"
Form_frmValueChain01.Form.frmValueChain16.LinkChildFields = "ID"
Else
Form_frmValueChain01.Form.frmValueChain07.LinkMasterFields = "txtMicroProcess01f"
Form_frmValueChain01.Form.frmValueChain07.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain14.LinkMasterFields = "txtMicroProcess01f"
Form_frmValueChain01.Form.frmValueChain14.LinkChildFields = "subprocessID"
Form_frmValueChain01.Form.frmValueChain10c.LinkMasterFields = "txtMicroProcess01f"
Form_frmValueChain01.Form.frmValueChain10c.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain101.LinkMasterFields = "txtMicroProcess01f"
Form_frmValueChain01.Form.frmValueChain101.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain07.LinkMasterFields = "txtMicroProcess01e"
Form_frmValueChain01.Form.frmValueChain07.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain17.LinkMasterFields = "txtSubProcessID"
Form_frmValueChain01.Form.frmValueChain17.LinkChildFields = "IDskillsmatrix"
Form_frmValueChain01.Form.frmValueChain16.LinkMasterFields = "txtSubProcessID"
Form_frmValueChain01.Form.frmValueChain16.LinkChildFields = "ID"
End If
Two things I see here;
Since you are using a less than operator, you seem to want to treat
this text box value as numeric. If so, you will need to convert the
text value of the text box to numeric.
Next,you need to prefix the reference to the text box with "me."
Your IF statement should look like this;
If val(me.txtDeviation01) < 1 Then
...

To handle the increment and decrement of a value in an expression and display the corresponding indicator SSRS reporting service

I have a table table of values displayed in SSRS .
The table has fields metricID , currentmonth , preciousMonth
Questions :-
1. I have to compare 2 values like current month and previous month
Fields.PreviousMonth.Value < Fields.CurrentMonth.Value
THEn Check if the metric id is metricID is 7 then increase in currentmonth should be displayed as up arrow with red colour else it should be downarrow with green colour.
For all other Metric ID's it should be "upp arrow with green colour" else "down arrow with red colour"
Does anybody have an idea on how to do this
To do this you will need to set up custom indicators and set an appropriate expression to set the indicator.
I have some simple data:
And a simple report with an indicator per row:
The indicator is set up as:
Where the expression is:
=Switch(Fields!MetricID.Value = 7 and Fields!CurrentMonth.Value - Fields!PreviousMonth.Value > 0, 1
, Fields!MetricID.Value = 7, 2
, Fields!MetricID.Value <> 7 and Fields!CurrentMonth.Value - Fields!PreviousMonth.Value > 0, 3
, true, 4)
So what I'm doing is assigning each row a specified state based on your business rules, and I've set appropriate icons for each of those states.
Report is working as required:
You could move the expression above into a calculated field in the Dataset if you needed to use it in multiple places in the report.

Multiple address rows with state list based on country

I have multiple address rows with a state and country combo box. I limit the state list based on the country. It looks like
However, when I change the value of the state and this detail row loses focus, it saves and clears the value of the other state like
I have an event on the state field to set the list when it gets focus.
Private Sub cboState_GotFocus()
MsgBox ("Country: " & Me.cboCountry.value)
If Nz(Me.cboCountry, 0) = 0 Then
MsgBox "Please select a country first"
Me.cboCountry.SetFocus
Else
If Nz(Me.cboCountry.value, 0) = 0 Then
Me.cboState.RowSource = ""
Else
Me.cboState.RowSource = "SELECT id, stateCode, stateName FROM state where country_id = " & Me.cboCountry.value
End If
End If
End Sub
I tried setting 'Limit to List' to No, but it gave an error
I tried setting Column Widths to 0.001";0.3938";1.1806", but then it displayed the id field instead of the state code. Here are the current values
Column Count 3
Column Widths 0";0.3938";1.1806"
Row Source SELECT id, stateCode, stateName FROM state where country_id = [country_id]
Bound Column 1
Limit to List Yes
How can I have multiple state combo boxes, each with a different restricted list based on the country?
An Access combobox whose LimitToList property is set to Yes can only show values returned by the RowSource property, even if the ControlSource is set to another value.
The workaround is to put a textbox on top of the combobox (but not covering the arrow) and show the text value in the textbox, using =Dlookup("textvalue","tbl","Id = " & numericvalue) in the ControlSource property. That way you can show a value that is not in the list.