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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send selected combo box value INTO text box on ANOTHER form.

Status
Not open for further replies.
Aug 19, 2008
11
US
Hey guys. I have a combo box(File_Name) which is getting populated from a table. I want the user to select a file from the drop down, and when they click on "open" or "run it will open a Microsoft word document as well as open another form. This works fine, but here's the problem.

For the past two days I've been searching, and have been struggling with the code to simply get whatever is selected from the combo box to automatically populate a text box(Form_Modified) on this pop up form.

Sorry for the newness, but I just can't seem to pass this god damn parameter to auto fill into the text box...help would be greatly appreciated.
 
Have you considered openargs for the second form?

DoCmd.OpenForm "Form2",Openargs:= Me.txtFilename
 
Or maybe use a global variable to pass the value to the second form...

Code:
'Global Variable in Module
Global gstrFileName As String

'Code on Form1
Private Sub cboCombo_AfterUpdate()
    gstrFileName = Me.cboCombo
End Sub

Private Sub cmdRun_Click()
   DoCmd.OpenForm "form2"
End Sub

'Form2
Private Sub Form_Load()
Me.txtFormModified = gstrFileName
End Sub



Pampers [afro]
Keeping it simple can be complicated
 
is there something i'm not getting? Upon using a msgbox to output the global variable from pampers example i keep getting nothing.
 
How are ya starbai007

Referencing [blue]Pampers[/blue] code, try:
Code:
[blue]gstrFileName = Me![[purple][B][I]YourComboName[/I][/B][/purple]].Column(index)[/blue]
Note: column index starts at zero and includes any widths set to zero in the [blue]Column Widths[/blue] property. I'm guessing the indes should be 1.

[blue]Your Thoughts?[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top