Topics Search

Set the value of a textbox based on the value of another textbox

Set the value of a textbox based on the value of another textbox
Views: 2289
What VBA code do I use to set the value of a textbox based on the value of another textbox?
Sponsored Links:

Similar posts...

 

AfterUpdate Not Firing

AfterUpdate Not Firing Icon
I have a subform which has a textbox in the footer which calculates a total amount. On my main form I have a textbox with the control source set to the textbox on my subform.

What I want to do, is every time this textbox changes, to update another textbox with the same amount. So Textboxtotal and TextboxCopy are the same all the time.

I understand that the afterupdate event wont fire as it is not updates via keypress, but I'm stuck there.
 

Show Label & Text Box in Report based on Checkbox

Show Label & Text Box in Report based on Checkbox Icon
I am attempting to show a label and textbox based on a checkbox in a report. The report is based on a SQL query joining two tables. The checkbox field is included in the query. Currently in the properties, I have the label and textbox .visible = false. I would like to set the label and textbox to
visible when the checkbox response = Yes.

I tried the OnLoad event of the form

Private Sub Report_Load()
If Checkbox = "Yes" Then
Label.Visible = True
Textbox.Visible = True
End If
End Sub

This didn't work. I am unable to define the event for the textbox and label directly because this is a report and not a form.
 

SelStart not accounting from spaces?

SelStart not accounting from spaces? Icon
So I have a textbox in the header of one of my forms. For it's On Change event I have it filtering the form based on whatever is entered in the textbox. This works great. However, after the filter is re-applied after each "change", I have SelStart code to place the cursor back in the textbox.

Problem is that SelStart does not seem to be accounting for any spaces in the textbox, and continues to place the cursor after the last character - not space - in the textbox.
 

TextBox Content

TextBox Content Icon
I have made an application with some textbox. I found that when I click on a textbox, its content and texts are moved to right. It seems there is one space at the begin of the textbox.
 

DLookup with Null criteria

DLookup with Null criteria Icon
But I'm running into this issue. I have a textbox with a control source as a DLookup. The recordset contains IDs from different tables, and I want the customer name to display in a textbox related to the customer id. but this is what I have/get

textbox = #Name? when CustID is null, using Nz and setting the textbox to an empty string if there was no Customer id

=IIF(IsNull(CustID).) and =IIF(Not IsNull(CustID). And still the textbox always turns up as #Name?

I tried to evaluate the code in vba and even when CustID is null, it still attempts to evaluate the DLookup instead of just giving me the appropriate value.

I realize that I can set the value of this textbox on Current event, or through VBA using simple If statement, but is there a solution where I can just set the controlsource in design to evaluate it?
 

Enable checkbox when locked textbox changes

Enable checkbox when locked textbox changes Icon
I have a form that has a locked textbox and other textboxes (not locked) and some checkboxes. I would like to enable two of the checkboxes when the data on the textbox changes. I added a not visible textbox with the control source of the locked textbox and used it's afterupdate event, but this does not fire as I tab through the records. What do I need to do to make thiswork?
 

sorting data in a textbox control

sorting data in a textbox control Icon
To sort data in a txt box. I am using this textbox on a report and have concatenated group totals in the textbox.

I need to find the Median of the list and in order to do this, the list, in the textbox needs to be sorted.
 

data from one form to another form..

data from one form to another form.. Icon
I have 2 tables in microsoft access with corresponding forms (table1:form1) & (table2:form2). in form1 I have 3 fields: result(dropdown) & name(textbox)&address(textbox).in form2 I have 2 fields: name(textbox)& address(textbox).

what I want is when I choose the "POSITIVE" in the form1 result(dropdown),the name(textbox)and address(textbox) I entered are copied to name(textbox) & address(textbox) inform2 and this will happen as I exit the form1 or if ill make a new record.
 

Form Focus?

Form Focus? Icon
I have a very simple program. 2 tables and 1 form. The form is used to look up and display data from the tables. I set the form up to be a popup and I minimize the Access database with [DoCmd.RunCommand acCmdAppMinimize].

I also set the focus to the input textbox since it is the only box that can be typed into. Everything works great. The cursor shows up and blinks in the input textbox, but when I try to enter something in the input textbox nothing happens. The form does not have focus so the typing does not show up until I click on the form or the textbox with the mouse and the form regains focus.

I have tried everything I can think of to get the form to have focus when it pops up but to no avail. Anyone have any ideas on how to fix this or is it just a pipedream on my behalf?
 

TextBox calculation

TextBox calculation Icon
I have a Form with textboxes,combobox and a button to calculate the discount level (comboBox) discount total (textbox), tax total (textbox) and total all these up into the total order(textbox) this is working except the discount total textbox...