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!

saving value of listbox before closing form

Status
Not open for further replies.

lanelouna

Programmer
Dec 19, 2002
71
GB
Hello,
I have a simple question to many of you, if you can help that would be great.
in fact, I have a form where the user is aked to enter a number which corresponds to the number of scenario he wants to analyse. then the user presses the ok button, this will open for him a dialogue box in a new form "choixmodal" in which he has to select the mode for the first scenario in a listbox group "cadremode". then the user has to press ok, which will close the form.
the question is, how can i save the value of the listbox "cadremode" before the form "choixmodal" is closed?


thank you in advance.
L.

P.s: the form is closed using a sub

Private Sub CommandeChoixmode_Click()


On Error GoTo Err_CommandeChoixmode_Click

DoCmd.Close

Exit_CommandeChoixmode_Click:
Exit Sub

Err_CommandeChoixmode_Click:
MsgBox Err.Description
Resume Exit_CommandeChoixmode_Click

End Sub



 

The simpliest way I can think of would be to go to a module and declare a global variable, say:

Code:
Public strListBoxChoice As String

then assigning the listbox value to it.

Code:
Private Sub CommandeChoixmode_Click()


On Error GoTo Err_CommandeChoixmode_Click

[COLOR=red]strListBoxChoice = Me.[i]YourListBoxName[/i].Value[/color]     

   DoCmd.Close

Exit_CommandeChoixmode_Click:
    Exit Sub

Err_CommandeChoixmode_Click:
    MsgBox Err.Description
    Resume Exit_CommandeChoixmode_Click

End Sub

This would make the List Box choice available project wide.

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
it worked!
thanks, you helped correct for the missing link
missinglinq!
thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top