Refresh Textbox with new data

sasi02

New member
Local time
Today, 13:50
Joined
Feb 28, 2008
Messages
5
I am having the textbox1 which get populated with data (select distinct [column name] from table). so when i run the form, it will give me n no of text box with data. I have another text box2 which get the value of text1.value and updates text2. when i click the button update it should update the text1 with new data which i have modified in text2. But i dont know what code to be written.
 
so if I'm understanding correctly, you have a textbox1 that is being populated with data from a query that you posted, and somehow (you didn't say how) you have textbox2 being populated with the same data, and you want a button that saves changes to textbox2 into textbox1. Begs the question, why are you bothering to go this route? You can "undo" any changes before they are saved in case the user types something in when they aren't supposed to. You could even save the old value into a variable or into an archive table in case they want to undo it after saving, or archive the changes made to the field.

Anyways, to make the text of textbox1 equal to that of textbox2, all you would need is
formName!textbox1.text = formName!Textbox2

that should do the trick unless you're using a "caption" or "label" instead of an actual textbox control. If that is the case, then you would use
formName!textbox1.caption = formName!Textbox2.caption
 
To make ny question clear, can you see the attachment given.


:(
so if I'm understanding correctly, you have a textbox1 that is being populated with data from a query that you posted, and somehow (you didn't say how) you have textbox2 being populated with the same data, and you want a button that saves changes to textbox2 into textbox1. Begs the question, why are you bothering to go this route? You can "undo" any changes before they are saved in case the user types something in when they aren't supposed to. You could even save the old value into a variable or into an archive table in case they want to undo it after saving, or archive the changes made to the field.

Anyways, to make the text of textbox1 equal to that of textbox2, all you would need is
formName!textbox1.text = formName!Textbox2

that should do the trick unless you're using a "caption" or "label" instead of an actual textbox control. If that is the case, then you would use
formName!textbox1.caption = formName!Textbox2.caption
 

Attachments

Yes, I can see the document ... so, you have a list of "report periods" and you want someone to be able to click on any given on in the list, fill that value into an unbound text box, then when the user changes it and clicks "update" that old value is updated with the user's changes. Is this sound right?
 
Yes, I can see the document ... so, you have a list of "report periods" and you want someone to be able to click on any given on in the list, fill that value into an unbound text box, then when the user changes it and clicks "update" that old value is updated with the user's changes. Is this sound right?

Yes you are right. That portion of coding i have done. But there is another button REFRESH. When i click that it, should list the updated periods in the text1 coulmn.
 
How to update that list depends on how you are filling in that list in the first place. For example, is this a continuous form (looks like the tabular wizard) and your data is bound to the form directly? or are you using some other method. Since your query.doc shows the Update/Refresh section is on the form footer, I am assuming you are binding the form directly to the data and using a continuous form.

If this is the case, then you can most likely place the following code behind the buttons on_click event

me.refresh
or
me.requery

If neither of these do the trick, or if you are filling in your data using another method, let me know.
 
Yes, i am using continuous forms only. I tried those 2 methods. But it is not working. :(
 
I apologize for this, but after I re-looked at what I posted and saw that you said it didn't work, I know exactly what happened, and I don't know why I even thought that a simple refresh/requery would do the trick. I completed spaced when I posted that, and am suprised, especially since I even re-opened the query.doc that you posted, before I posted the refresh/requery solution.

Anyways, what you'll have to do is figure out some way to capture the original value that is needing to be changed, then write some VBA code that will update that particular value to what the user changed.

Here is my recommendation, and you can probably come up with a way to implement this using your existing form, but I would like to recommend a different approach.

Make an event procedure for the field used in the continuous form on the field that you are wanting to change (either On_Click or On_DblClick, I would use the dbl myself, but that's just preference).

There are probably many different ways of doing this, and I'll post the way I would do it.

Dim strOldValue as String, strNewValue as String
strOldValue = me.fldName

strNewValue = inputbox(Prompt:="Enter new value", Title:="Some title", Default:=strOldValue)

docmd.runsql "Update tblName SET tblName.FieldName = '" & strNewValue & "' WHERE (((tblName.FieldName)='" & strOldValue & "'));"

That should do the trick.
 
Hi,

Thank you so much for your advice. It worked now.
Along with your query i included me.requery, which updates the form with the new distinct values.
:o

Once again thanks a lot.
 
I would like to do something very similar as you but I am having a difficult time.. In a form I have a textbox where a user will put a date (January 1, 2011). The user will also choose a report. After they click the command button what I want access to do is find that report, find the unbound textbox [Text4] and have it equal "Effective: January 1, 2011) I am having some trouble however identifying the report/textbox. My code is:

edate = Me.Text126
Debug.Print Cname
Reports!" & Cname & "!Me.Text71 = "Effective: " & edate

edate and cname is defined and definitely does work because it is used in the code prior. It is giving me an error at the red exclamation point.

Any suggestions? Thanks for any and all help
 

Users who are viewing this thread

Back
Top Bottom