How to have combo box in one form select record to be used in another form 
Author Message
 How to have combo box in one form select record to be used in another form

I am trying to figure out how to have a combo box select a record and
then "remember" that record so that I can close that form and go to a
series of other forms which will then use the chosen record.

I have done this using "wizards" to have a form chose this for a
subform, but this project is more complicated and I would have to have a
long multi-page form -- and already some of my modules that worked
within the subform when it was running on its own, don't seem to work
when put within a larger form.

Suggestions would be most welcome.



Sun, 02 Jan 2000 03:00:00 GMT  
 How to have combo box in one form select record to be used in another form

I have used 3 different solutions to this problem - depending on the
desired behavior of the second, third, ... forms.

1)  DoCmd.Openform "Form2",,,"[myField] = " & [myCombo]
        This opens Form2 with only the record(s) with the desired value.

2)  The last argument of the Openform method sets the OpenArgs property of
the form you are opening.  You can pass any string you want - and use it in
the OnOpen routine for the new form.

3)  Rather than closing Form #1, you can hide it.  (me.Visible = False)
Then you can refer to the value in your combo box directly in all of the
forms that follow..  Forms!form1!myCombo

Hope this helps.
Bill Minser



Quote:
> I am trying to figure out how to have a combo box select a record and
> then "remember" that record so that I can close that form and go to a
> series of other forms which will then use the chosen record.

> I have done this using "wizards" to have a form chose this for a
> subform, but this project is more complicated and I would have to have a
> long multi-page form -- and already some of my modules that worked
> within the subform when it was running on its own, don't seem to work
> when put within a larger form.

> Suggestions would be most welcome.



Sun, 02 Jan 2000 03:00:00 GMT  
 How to have combo box in one form select record to be used in another form

Robert,

This is really not a problem.  I hope you know how to code.

I would do it this way.

Go to the modules tab and create a new module.  I would name this module
basGlobals.  Inside this module create your global variable.

    i.e. Global MyVariable as Integer
Once you have done this you can save and close the module.  Go to your
form and the properties of the combo box.  Under the After Update Event
enter this code.

    MyVariable = Me!MyCombo

This will set the global variable of MyVariable equal to the bound
column of the combo box.  If you want a different column (Like an id
field that you are not showing the user) enter it this way

    MyVariable = Me!MyCombo.Column(0) (The columns are zero based)

Now when you go to close this form the variable is still set and now you
can open the other forms.  If your other forms are using this variable
as an id to filter to I would create a query to put in the forms
Recordsource property and with a function in the criteria section that
retrieve the variable value.

    i.e. Public Function GetValue() as Integer
            GetValue = MyVariable
          end function

Now whenever you open the form (so long as the variable is set) the form
will always open to view the correct record.  Simple as that.  Have fun.

Erik
Software Engineer

Quote:

> I am trying to figure out how to have a combo box select a record and
> then "remember" that record so that I can close that form and go to a
> series of other forms which will then use the chosen record.

> I have done this using "wizards" to have a form chose this for a
> subform, but this project is more complicated and I would have to have
> a
> long multi-page form -- and already some of my modules that worked
> within the subform when it was running on its own, don't seem to work
> when put within a larger form.

> Suggestions would be most welcome.



Mon, 03 Jan 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Please comment on my ugly code- for retrieving record on a form using a combo box

2. selecting records for 2nd combo box dependant on first combo box

3. Having 2 Combo boxes on a form causes weirdness

4. Using a combo box to move to selected record

5. Using Combo Box to Select Records on From

6. Using a combo box to select a record

7. Using combo box to select a record

8. Cetting A Report To Select Records Based Upon A Value Selected In A Combo Box

9. Filtering Records on Form By Value of Other Combo Box

10. Record select in popup form to populate parent form

11. Linking Records form one form to another in VB 6.0

12. Multiple forms using Combo boxes

 

 
Powered by phpBB® Forum Software