Reference Table to fill calendar form - forms

In Access 2010, I've built a calendar Form that I want to be able to display who is off in a given month.
Each box of the calendar obviously represents a different day. I've got a table called "Separated" set up that ultimately stores the associate name and the date they are off -- one day per record.
Here's what I've done so far to try to test it on just one of the boxes (representing a day):
Private Function fillDays()
Dim rsNames As DAO.Recordset
Set rsNames = CurrentDb.OpenRecordset("SELECT * FROM Separated")
If Not rsNames.EOF Then
b0.Text = rsNames![Associate]
End If
Set rsNames = Nothing
End Function
I get the following debug note:
"Run-Time Error '2185"
"You can't reference a property or method for a control unless the control has the focus."
The debugger highlights the line with "b0.text = rsNames![Associate]
Is there some whay that I need to reference an index number from my "Separated" table?... or perhaps using a query method of some sort would be more effecient.

Assuming b0 is a textbox, the error you are getting is due to the fact that you can't use it's Text property when said textbox hasn't got the focus.
As stated in MSDN, «While the control has the focus, the Text property contains the text data currently in the control; the Value property contains the last saved data for the control. When you move the focus to another control, the control's data is updated, and the Value property is set to this new value. The Text property setting is then unavailable until the control gets the focus again» (emphasis mine).
Try using Value (help here) instead:
b0.Value = rsNames![Associate]

Related

Active reports textbox control

I am using Active reports 6 as Report Control in my .Net application.
How will I get the value of a data bound text box control after the control is initialized?
You can get the value after the data binding of each row which happens immediately before the section's Format event is fired.
In detail_Format event. you can retrieve the value using the textbox value or text properties
txtMyTextbox.Text (returns the formatted text that would render in the report)
txtMyTextbox.Value (returns the bound value, without formatting)
hope this helps.
http://activereports.grapecity.com

Updating the selected dropbox item in a GUI

Currently I have a GUI in which once a 'Submit' button is pressed the drop menu which is left blank is then populated by a calculated value determined by the three other values.
I have successfully figured out how to grab all of the values using this logic:
temp=get(handles.FSTOPpopmenu,{'String','Value'});
fstop=temp{1}{temp{2}};
if (strcmp(fstop,'Select'))
fstop = 0;
else
fstop = str2num(fstop);
end
I just have two questions about this that I can not seem to find an answer for.
How would I go about updating the 'empty' drop menu to the calculated variable (the calculated variable will already be one of the possible values in the predetermined list)?
How would I go about presenting an error, say if I have an if statement checking that the amount of zeros in the array? Would a pop up box be sufficient?
Cheers.
As for your first question matlab's set command is what you're looking for. The documentation is here. You would probably need:
MyValueIndex = find(DropDownValues==NewValue);
switch handleToChange
case handles.handle1
set(handles.handle1,'Value',MyValueIndex);
case handles.handle2
set(handles.handle2,'Value',MyValueIndex);
otherwise
error('Uh oh!');
end
Note that MyValueIndex is the index of dropdown box values that you want. Which is found with a find command on the actual value.
Question two is more of an opinion question but I think that a pop-up box describing the problem is sufficient. Maybe add in a system beep for good measure!
Reference:
http://www.mathworks.com/matlabcentral/answers/22734-resetting-a-pop-up-menu-in-a-gui
http://www.mathworks.com/help/matlab/ref/find.html
http://www.mathworks.com/help/matlab/ref/switch.html
For a popupmenu uicontrol the Value property determines which element of the String property is currently being displayed. Get the String; compare its contents to the calculated variable to get the index; then set that index as the Value property. If the calculated variable is not currently in the String then add it to the String and then set the Value. (Note when comparing you need to compare numbers to numbers or string to strings, so you may need to do an appropriate data type conversion first).
Use an errordlg.

How to design textbox visibility expression in SSRS?

I have an RDL with a table/textbox visibility set to:
=iif(Fields!question_caption.Value = "OBJECTIVE 1",false,true)
I am trying to make this textbox display the value named "narrative" only if the question_caption record = "OBJECTIVE 1". How can I do this? Currently this textbox displays nothing with the above logic. I have the narrative field stored in a Placeholder if that makes any difference.
Here is some sample data for you:
create table #dummy_data
(
question_caption varchar(max),
narrative varchar(max)
)
insert #dummy_data values('1st week dates','week 1'),('2nd week dates','week 2'),('3rd week dates','week 3'),('OBJECTIVE 1','obj 1'),
('5th week dates','week 5')
select * from #dummy_data
I don't see anything wrong with your visibility expression. However, in your question, you're discussing two separate things as one (i.e., visibility & displaying a value in a placeholder).
The hidden property will show an object (tablix, textbox, image, chart, container, etc) if the expression returns false and will hide an object when the expression returns true. When I say hide, I mean that it will remove the object from the grid and, if all is setup properly, the surrounding objects will be shifted to fill the now empty space of the hidden object.
To display (or not) a value is an entirely different thing. To show or hide a value, you would put the following expression in the value property of the placeholder:
=IIF(Fields!question_caption.Value = "OBJECTIVE 1",Fields!narrative.Value,"")
Notice that I've set it up such that if the desired value of the question_caption field is present, it will display the value of the narrative field. Otherwise, it will return an empty string. This will maintain the layout of the report but simply display the desired value or an empty string, based on some criteria.
As for the issues you're current experiencing, I'm not sure why that would be happening. I would first check that you don't have a typo in the Objective 1 hardcoded value in your expression.
If this doesn't help, please comment and let me know some more information about your problem and I'll do my best to help.

GWT DataTable TextInputCell is not showing the correct value

I have a DataGrid with a TextInputCell column, using a ListDataProvider. When the value in a cell is changed I am creating a RequestContext and calling RequestContext#edit with the original entity for the row that is being edited. I then set the field in the mutable version of the proxy to the value from the edited cell. This all works nicely, and I can save the change successfully to the database. However, on the server I modify the value before saving the change, and send the modified entity (DTO) back to the client. In the Receiver#onSuccess method I store the new entity in the list data provider, and then call ListDataProvider#refresh. But the value that is shown in the DataGrid doesn't change to reflect the modification on the server. I've looked at the value that is supplied to the TextInputCell#getValue method, and it is correct, that is, it is the value that contains the modification applied on the server.
I tried creating another column in the grid that is just a TextCell, and supplied the same value in getValue for that cell; in this case the displayed value is correctly updated by the refresh, reflecting the modified value that was returned from the server.
So, my question is: where does the cell get its value? When I look at the value returned by my TextInputCell#getValue method it appears to be the correct value, but that value is not being shown on the screen (the value shown on the screen is the value that was in the proxy object prior to sending the request to the server).
Note: I looked at this question, but it did not work in my situation.
I have a very similar problem.
I have a page showing a grid with two column: the first one has check boxes instead of text.
The value of the check box is given by:
public Boolean getValue(Item item) {
return selectedItems.contains(item);
}
When the user checks a check box, I store the value in a map (selectedItems).
At the bottom of the page there is a "Clear" button that reset the map and calls the table redraw, but the status of the check boxes does not revert to the original status (i.e. the check boxes stay selected).
Debugging the code I've found that getValue() returns the correct value, but is like the table caches the cells.
The only workaround I have found, without rebuilding the whole table, was to remove the check boxes' cell and add it again on "Clear".
itemsTable.removeColumn(0);
itemsTable.insertColumn(0, makeSelectionColumn());
The method makeSelectionColumn() must return a new cell.

How to update another text box while typing in access 2007 form?

I have a few text boxes which have to be filled with numeric values from 0 to 100. Below them there is another text box which stands for a total (the sum of the values from the text boxes above). How can I update the sum text box while typing in any of the other text boxes above?
If you are happy that the sum box updates after a box is updated (enter, tab or such like is pressed), then this can be done without any code. First, you will need to set the format of the textboxes to be summed to numeric, then the control source of the sum box becomes:
=Nz([text0],0)+Nz([text2],0)+Nz([text4],0)+Nz([text6],0)+Nz([text8],0) ...
Note the use of Nz, it may be possible to eliminate this by setting the default value property of the various textboxes to be summed.
A large set of controls that need to be summed in this way is often an indication of an error in the design of the database. You would normally expect this kind of thing to be a separate recordset, which could more easily be summed.
I know this is old, but Google didn't come up with much for this topic and this thread didn't really help either. I was able to figure out a very easy way to do this, so hopefully anyone else looking for this will find this helpful.
My need was for actual text as opposed to numbers, but the same applies.
To do what the OP is asking for you'll need at least 3 textboxes. 1 is the textbox you want to have updated each time you type, 2 is the textbox you will be typing in, and 3 is a hidden textbox.
Set textbox 1 to reference the value of the hidden textbox 3 in its control source:
="something in my textbox " & [textbox3]
In the OnChange event of textbox 2 right a line that will set the value of the hidden textbox 3 to the Text property of textbox 2 that you are typing in:
Private Sub textbox2_Change()
Me.textbox3.Value = Me.textbox2.Text
End Sub
Each time the value of the hidden textbox 3 gets updated, the calculation/reference in the displayed textbox 1 will be updated. No need to save caret locations or anything else mentioned in this post.
I was able to do this in Access 2007 by using the On Lost Focus event of the text box.
Just put something like this on the On Lost focus event of each text box that you want to be added , just make sure to set the default value of each text box to 0.
Me.Totals.Value = Me.Text1.Value + Me.Text2.Value + etc..
The moment you click on the next text box or anywhere as long as it loses focus, your sum will already be on the Totals box. You may add as many text boxes as you like, just include them in the code.
This is problematic due to the asinine requirement in Access that you have to set focus to text areas before you can get their value. I would recommend you change your design so that the text field is updated in response to a button click instead of on change.
If you want to go the update-on-change route, you would attach change events to each of the addend text fields. The event handlers would need to save the caret position/selection length, update the sum in the output text field, and restore the caret position. You need to save/restore the caret position because this is lost when the focus changes.
Here's an example for two text fields (txt1 and txt2). The output field is named txtOutput.
Private Sub txt1_Change()
Dim caret_position As Variant
caret_position = Array(txt1.SelStart, txt1.SelLength)
UpdateSum
txt1.SetFocus
txt1.SelStart = caret_position(0)
txt1.SelLength = caret_position(1)
End Sub
Private Sub txt2_Change()
Dim caret_position As Variant
caret_position = Array(txt2.SelStart, txt2.SelLength)
UpdateSum
txt2.SetFocus
txt2.SelStart = caret_position(0)
txt2.SelLength = caret_position(1)
End Sub
Private Sub UpdateSum()
Dim sum As Variant
sum = CDec(0)
txt1.SetFocus
If IsNumeric(txt1.Text) Then
sum = sum + CDec(txt1.Text)
End If
txt2.SetFocus
If IsNumeric(txt2.Text) Then
sum = sum + CDec(txt2.Text)
End If
txtOutput.SetFocus
txtOutput.Text = sum
End Sub