Access form / textbox default value problem - forms

I have an access continous form:
I placed a unbound text box txt1 in the header where user enters the number of the assignment. I want all rows in the form to have the same assignement number - entered only once in the header. (Later, txt2 would be hidden).
In the form, i added a another textbox and placed default value as =[txt1].
My problem is that this text is being populated only in the second row, when i start typing in the first row.
As this:
Refreshing does not help.
Any ideas?
Thank you!

Textbox 2 does not populate because the default value is not available when record edit is initiated by input into unbound textbox 1. Code will have to set Value of textbox 2 with the textbox 1 input. So with textbox 1 AfterUpdate event:
Me.textbox2 = Me.textbox1.
Alternative is to not use unbound textbox. Instead, use AfterUpdate event of textbox 2 to set its DefaultValue property. Subsequent records will populate with that value until user enters another and the DefaultValue will be reset.

Related

How to clear a SAPUI5 input field with only value help input allowed?

my SAPUI5 app has an input field where the valid values must be obtained through a value help:
<Input showValueHelp="true" valueHelpOnly="true"
valueHelpRequest="onValueHelpRequest"
value="{myModel>/myField}"
The value help is realized with a SelectDialog, where the only options are
choose one or
cancel
The problem is now the following flow:
User opens value help dialog to choose one item and presses Confirm
Input field now displays chosen value
User wants to clear the input, because it's optional
Unfortunately,
sap.m.Input doesn't provide a clear button
sap.m.SelectDialog doesn't provide the possibility to add a custom button like Clear
The input is layed out in a SimpleForm with 2 columns, labels and input fields, so it would be hard to add a clear button
The Gateway entity set which feeds the value help dialog list doesn't have a totally empty line
I don't like the workaround to switch the SelectDialog to multiSelect just for the purpose that the user can choose "one or none". I also think it would be hard to explain to the user "if you want to remove the value, hold the control key and click on the previously selected item again".
Any ideas out there how to easily implement a clear button or something similar?
valueHelpOnly="false"
// with this user can either fill by F4 (assisted input) or by typing input..
and if you want to clear you can add a button and set the value to null
oInput.setValue("");

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

Excel Form VBA Combobox reset

This should be easy but I can't seem to find anything to solve. I have a Form in Excel using VBA. The Excel sheet has four columns populated with data and the Form displays those fields.
The user then selects a value in a combobox, uses a command button to submit the responses and the values from the combobox are written to the Excel sheet.
The user then uses a command button to advance one row down in the spreadsheet and load the four values from a new row. This all works great.
The issue I am trying to solve is that the combobox remains selected to the value in the prior selection. I'd like to reset the combobox so nothing is selected and the user has to make a selection again for the next row.
Below is the code I am using to load the combobox and to set a variable for what the user selected. Can't seem to get the combobox back to it's default state after the user has submitted the form.
Private Sub cbDesAccWanted_Change()
Select Case cbDesAccWanted.Text
Case "Yes"
desacc = "Yes"
Case "No"
desacc = "No"
End Select
cbDesAccWanted.Text = desacc
End Sub
Private Sub cbDesAccWanted_DropButtonClick()
cbDesAccWanted.List = Array("Yes", "No")
End Sub
There are two ways to reset the combobox. Take your pick:
1
cbDesAccWanted.Value = Null
2
cbDesAccWanted.ListIndex = -1
the line
cbDesAccWanted.Text = desacc
is totally unnecessary.
Using cbDesAccWanted_DropButtonClick is not the right place to populate the list of values. This list should be set up when the form is first shown to the user.
(unelss the values it shows chnages in which case change it when the row changes or something, not when the user clicks on it)
So when theuser clicks the down arrow to move to thenext record include the following line
Me.cbDesAccWanted.text = Me.cbDesAccWanted.List(1)
Note (1) access teh 2nd item in the list which is No.
So this reset it to the default value of No.
Ok.

I have a listbox. How do I select the 3rd item in the listbox out of many items?

I have a form with 10 listboxes on it. I also have a command button. How do I make it so that if I press the command button it will select the 3rd item of a listbox of my choosing?
You may do so by converting your 10 listboxes into a control array. If I remember correctly, you do so by specifying the same Name property and a unique, non-negative Index property for each one of the ListBox instances in your form.
Assuming you named all of your list boxes as ListBoxArr and set up the Index property so that the first listbox is 0, the second one is 1, etc. then you can write something like this
' Access the 6th list box and select the third item
' Remember, Index values are zero-based, so 0 is first item...
ListBoxArr(5).ListIndex = 2

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