PDA

View Full Version : Solved: Textbox code not working on subform



hunsnowboard
06-09-2011, 02:08 AM
Hi there Everyone!
I have a problem with displaying data in a textbox. Here is my problem:
I have a form and on the form I have a listbox and a textbox. As I click on one of the records on my listbox (the listbox contains names) the textbox shows the description for that name.
Here is my working code:


Private Sub List0_Click()
If Not IsNull(Me!List0) Then
Me!txtTitle = Me!List0.Column(3)
End If
End Sub


This code is working very well. However when I put my textbox to a subform then the code is not working anymore and gives me an error. I am sure that the problem is that I put the textbox on a subform.
What do I need to change in my code to run on subform as well?
Thank you very much for your help in advance!

hunsnowboard
06-09-2011, 04:44 AM
Hi All! Ok, I figured it out that I have to explain to Access that I am using a subform.

Now my code looks like this:


Private Sub Lista0_Click()
If Not IsNull(Me!Lista0) Then
Forms!Urlap3!Urlap4.Form!txtAngi = Forms!Urlap3!Lista0.Column(0)
End If
End Sub


Urlap3 = mainform
Urlap4 = subform
txtAngi = textbox

I keep getting the runtime error 2465- "Microsoft access cant find the field "Urlap4" error message.
I checked everything and I have Urlap4 form and I have txtAngi textbox on that form.

Please help!

hunsnowboard
06-09-2011, 04:53 AM
Woohoow! Got it worked out! The main form was referencing to the old name of Urlap4. Had to change the name and works like charm!
Thank you!