updating bounded text box in pop-up form

  • Thread starter Thread starter George Papadopoulos
  • Start date Start date
G

George Papadopoulos

Hello everybody


I have two built two forms with the controls on each form bounded to two
different tables. There exists a button on the first form which when pressed
pop-ups the second. By using an event handler for the on-click event I want
to assign a text box value on the second form by making equal to the another
text box value on the first form. The code, I am using now is :

Private Sub Add_spare_Click()
On Error GoTo Err_cmdGoHere_Click
Dim stDocName As String

Me.[Kwdikos episkeyhs].SetFocus
varvc = Me.[Kwdikos episkeyhs].Text

stDocName = "STOIXEIA_ANTALLAKTIKWN"
DoCmd.OpenForm stDocName

Me.[Kwdikos episkeyhs].SetFocus
Me.[Kwdikos episkeyhs].Text = varvc

Exit_cmdGoHere_Click:
Exit Sub

Err_cmdGoHere_Click:
MsgBox Err.Description
Resume Exit_cmdGoHere_Click


End Sub

When I press the button I get the error : 'The property is read-only and
can`t be set'.

Is there any way I can change the read-only property? I have not told
Access that the text box should be read-only. Could this problem stem from
the fact that the text-box is bounded to a table? How can I go about this?


Any help would be appreciated

George Papadopoulos
 
George said:
Hello everybody

I have two built two forms with the controls on each form bounded to two
different tables. There exists a button on the first form which when pressed
pop-ups the second. By using an event handler for the on-click event I want
to assign a text box value on the second form by making equal to the another
text box value on the first form. The code, I am using now is :

Private Sub Add_spare_Click()
On Error GoTo Err_cmdGoHere_Click
Dim stDocName As String

Me.[Kwdikos episkeyhs].SetFocus
varvc = Me.[Kwdikos episkeyhs].Text

Looks Greek to me. (Sorry, couldn't resist that one)
stDocName = "STOIXEIA_ANTALLAKTIKWN"
DoCmd.OpenForm stDocName

now your form is open, refer to it! Not
Me.[Kwdikos episkeyhs].SetFocus
Me.[Kwdikos episkeyhs].Text = varvc

but

With forms(stDocName)
.[Kwdikos episkeyhs].SetFocus
.[Kwdikos episkeyhs].Text = varvc
End With

Do you need to set the Text property? You can set the Value even if the
control doesn't have the focus. Applies to both Me (whatever its name
is) and stoixeia antallaktikoun.

Yia sou.
 
Hi,


While in VB6 the default property of a text edit control is TEXT, in
Access, the default property is VALUE. In Access, TEXT can only be reach if
the control is in focus, since it describe "what the user is actually seeing
(typing)". The VALUE property, on the other hand, is the last value checked
locally (fields validations included, but no records validations yet).
OldValue, another property, refer to the last value globally checked (fields
AND table validations AND relational data integrity applied). You also have
DefaultValue, the value used when the user create a new record.


So, replace
Me.[Kwdikos episkeyhs].SetFocus
varvc = Me.[Kwdikos episkeyhs].Text ...
Me.[Kwdikos episkeyhs].SetFocus
Me.[Kwdikos episkeyhs].Text = varvc


by


varvc = Me.[Kwdikos episkeyhs].Value
...
Me.[Kwdikos episkeyhs].Value= varvc


or just

varvc = Me.[Kwdikos episkeyhs]
...
Me.[Kwdikos episkeyhs] = varvc

since Value is the default property,


If varvc is not used anywhere else, by just:




Me.[Kwdikos episkeyhs]= Me.[Kwdikos episkeyhs]




but that does not seem to make sense. If either side refers to ANOTHER form,
do not use ME, ME is the form that runs the code, NOT necessary the form
having the focus. Instead, try something like:



Me.[Kwdikos episkeyhs].Value =
FORMS!OtherFormNameHere!ControlNameHere.Value



where FORMS is a keyword to by typed as it is. You can remove the
dot-Value, I just included them to be more "explicit" about what I want.
That formulation is independant of which form has the focus: me= the one
who runs the code, and FORMS describe the other form, explicitly, by name.
It is thus much safer than to relay on "who has the focus" (on slow
computer, or with fast end user).



Hoping it may help,
Vanderghast, Access MVP


George Papadopoulos said:
Hello everybody


I have two built two forms with the controls on each form bounded to two
different tables. There exists a button on the first form which when pressed
pop-ups the second. By using an event handler for the on-click event I want
to assign a text box value on the second form by making equal to the another
text box value on the first form. The code, I am using now is :

Private Sub Add_spare_Click()
On Error GoTo Err_cmdGoHere_Click
Dim stDocName As String

Me.[Kwdikos episkeyhs].SetFocus
varvc = Me.[Kwdikos episkeyhs].Text

stDocName = "STOIXEIA_ANTALLAKTIKWN"
DoCmd.OpenForm stDocName

Me.[Kwdikos episkeyhs].SetFocus
Me.[Kwdikos episkeyhs].Text = varvc

Exit_cmdGoHere_Click:
Exit Sub

Err_cmdGoHere_Click:
MsgBox Err.Description
Resume Exit_cmdGoHere_Click


End Sub

When I press the button I get the error : 'The property is read-only and
can`t be set'.

Is there any way I can change the read-only property? I have not told
Access that the text box should be read-only. Could this problem stem from
the fact that the text-box is bounded to a table? How can I go about this?


Any help would be appreciated

George Papadopoulos
 
Back
Top