from a listbox to a textbox

  • Thread starter Thread starter John
  • Start date Start date
J

John

Greetings.
I have a form with a single select list box on it. Also
on the form is a button. On another form I have a
subform. In the subform is a textbox. I am trying to
find a way to have the selected list box item show up in
the textbox when I select it and click the button. I am
not succeeding.
Anyone have a way for this? Or can point me to a website
that has the info?
Thanks in advance for the response.
*** John
 
John,

On the subform, select the textbox, open properties, go to the Data tab and set
Enabled to No and Locked to Yes. This will make it so you can't set focus on the
textbox and therefore can't enter anything into the textbox. Next put a button
on the subform with the caption "Enter Value In Textbox". Put the following code
in the OnClick event of the button:

DoCmd.OpenForm "NameOfFormWithListBox",,,,,acDialog
Me!NameOfTextBox = Forms!NameOfFormWithListBox!NameOfTextbox
DoCmd.Close acForm, "NameOfFormWithListBox"

Now go to the form with the listbox. Delete your button there. Put this code in
the AfterUpdate event of the listbox:

Me.Visible = False

The acDialog in the code behind the button on your subform causes the code to
halt until the form you opened becomes not visible or is closed. The code in the
Afterupdate event makes the listbox form not visible so then the code behind the
button resumes filling in the textbox and finally closing the listbox form. You
don't want to close the listbox form when you make a selection because you need
it open for the subform to retrieve the value.


--
PC Datasheet
A Resource for Access, Excel and Word Applications
(e-mail address removed)
www.pcdatasheet.com

· Design and basic development for new applications
· Additions, Modifications and "Fixes" for existing applications
· Mentoring for do-it-yourselfers who want guidance
· Complete application design and development
· Applications Using Palm Pilot To Collect Data And
Synchronize The Data Back To Access Or Excel
 
Didn't I answer this question in another newsgroup?

You'll do everyone, especially yourself, a favor to avoid "multiposting" --
that is, individually posting the same question in multiple newsgroups, as
it appears you did this one. If you feel compelled to post the same question
to multiple newsgroups (it rarely is needful), the learn to crosspost, so
the answers in one newsgroup will appear in the other, as well.

For other good suggestions on effective use of newsgroups, visit the FAQ at
http://www.mvps.org/access/netiquette.htm.

Larry Linson
Microsoft Access MVP
 
Yes Larry, you did answer this in another newsgroup. I
posted my apology on the other newsgroup for the double
posting. As I mentioned, I didn't expand far enough,
posted, then realized it was the wrong group and posted
it again in this group. I realized my error on double
posting when I hit the Send button. So I posted my
apology for double posting. As I apologize in this group
as well.
*** John
 
Back
Top