Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble setting textbox value from within Click event of listbox

Status
Not open for further replies.

cadoltt

Programmer
Jun 9, 2005
85
CA
Hi Everybody,


On my form I have a list box and a text box controls. When a user clicks an item in the list box I need the value to appear in the text box. So I put the the following piece of code into the Click event of the list box:

Code:
Private Sub lsb_myList_Click()
  Dim str_value As String

  ...
  
  txb_myText.SetFocus
  txb_myText.Text = str_value
  
  ... 
  
  Form_myForm.lbl_myLabel.Caption = str_value
  Form_myForm.Repaint

End Sub


However when I run the form and click an item I get the following error mesage:

Runtime error '2115'.

The macro or function set to the BeforeApdate or ValidationRule property for this field is preventing the form from saving the data into the field.


And the debugger points to the line

txb_myText.Text = str_value.


I suspect that the error might occur because I am trying to set the value of the text box while my list box holds the focus but I am not sure if this is the case since the value appears in the label okay (note two last lines of the code).

BTW, when I stop the debug I see the value in the text box despite the error message.


Can anyone help me fix this?


Thanks,

Alex
 
rjoubert,

Thanks a lot for your quick response, it works now!


Alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top