One textbox updates, another doesn't, same code... (1 Viewer)

Adam Caramon

Registered User
Local time
Today, 08:29
Joined
Jan 23, 2008
Messages
822
Ok, this is very strange. I have a form with various textboxes and a refresh button. The button calls on_click UpdatePreview. UpdatePreview looks like this:

Code:
if condition 1 = true then
      if condition 2 = true then
            if condition 3 = true then
                  if isNull(me.textbox1.value) then
                        me.previewtextbox1.value = ""
                  else
                        me.previewtextbox1.value = me.textbox1.value
                  end if
                  if isNull(me.textbox2.value) then
                        me.previewtextbox2.value = ""
                  else
                        me.previewtextbox2.value = me.textbox2.value
                  end if
            end if
      end if
end if

Now, when I make changes on the live form to textbox1, then click the Update Preview button, the changes are reflected in previewtextbox1. When I make changes in textbox2, then click the Update Preview button, the changes are not reflected in previewtextbox2.

My Form_Current event also runs UpdatePreview. So if I make changes to textbox2, move a record forward, and then move a record back, the changes are reflected. There's nothing else running in Form_Current.

So I assumed that the fact that the record is saving is what is causing this issue, and that seems to pan out. I added a second button (Save record, default button wizard). If I make changes to textbox2, then click the save button, then click the UpdatePreview button, the changes take affect.

What am I missing? Why do the changes for textbox1 automatically update while those for textbox2 require a save?

Thanks in advance.
 

dragofly

Registered User.
Local time
Today, 07:29
Joined
Aug 3, 2010
Messages
23
If it were me I would be hitting tab after editing the first and leave the cursor in the second textbox before hitting the button, thus the second textbox would not update in the underlying value as in the detail it is still selected and the button would have to be in the header or footer section of the form.

If this doesn't make sense just try typing into the first textbox and without hitting tab or anything at all else click directly on the button and see if it works the same.
 

Kryst51

Singin' in the Hou. Rain
Local time
Today, 07:29
Joined
Jun 29, 2009
Messages
1,898
If its the case of what dragonfly says you could put an

If Me.textbox2.dirty = true then
Me.textbox2.dirty = false

kind of thing in there.
 

Users who are viewing this thread

Top Bottom