Can a listbox be used to pop up a form based on selection?  | Familiar Sight | | Join Date: May 2007
Posts: 222
| | |
Hellol,
I'm again in need of your help with my Order processing system..
My Order form is based on (query) of Customer and Order tables (includes a subform for the product data)...has a listbox (values are check or credit card)...to store the payment type. What I'm looking for is a way to pop up a form based off either a credit card or a check selection. Either form would then store their data into the Payments table (used for report processing) i.e, paymentID, cardholder's name, exp date, last 4 digits of card, routing number, etc.........
I would actually like to have a textbox (for storing the check number/routing number)....Possibly have it be not active until the check selection is made in the listbox; then for a credit card selection, a small form to popup for additional information.
Help, does anyone understand what I'm trying to do and better yet, if someone has done this, could you point me to a sample form (similar)??? thanks so much, in advance.
Rosie
|  | Expert | | Join Date: Apr 2006 Location: Philadelphia
Posts: 5,214
| | | re: Can a listbox be used to pop up a form based on selection? Quote:
Originally Posted by imrosie Hellol,
I'm again in need of your help with my Order processing system..
My Order form is based on (query) of Customer and Order tables (includes a subform for the product data)...has a listbox (values are check or credit card)...to store the payment type. What I'm looking for is a way to pop up a form based off either a credit card or a check selection. Either form would then store their data into the Payments table (used for report processing) i.e, paymentID, cardholder's name, exp date, last 4 digits of card, routing number, etc.........
I would actually like to have a textbox (for storing the check number/routing number)....Possibly have it be not active until the check selection is made in the listbox; then for a credit card selection, a small form to popup for additional information.
Help, does anyone understand what I'm trying to do and better yet, if someone has done this, could you point me to a sample form (similar)??? thanks so much, in advance.
Rosie Hello Rosie!
Is your request to open 2 different Forms based on whether the selection in a List Box is either Check or Credit Card? If this is not the case, please provide additional information, if it is, please provide the Name of the List Box as well as the Names of the Forms and I'll get back to you.
|  | Familiar Sight | | Join Date: May 2007
Posts: 222
| | | re: Can a listbox be used to pop up a form based on selection? Quote:
Originally Posted by ADezii Hello Rosie!
Is your request to open 2 different Forms based on whether the selection in a List Box is either Check or Credit Card? If this is not the case, please provide additional information, if it is, please provide the Name of the List Box as well as the Names of the Forms and I'll get back to you. Hi ADezii,
Yes, you got it. They're two different forms gathering different info (but each will store into the Payments table). The listbox is called 'paymnt'.
I'm thinking of putting this behind a cmd button... - If Me.MyListBox.Value = 1 Then
-
DoCmd.OpenForm "Form1"
-
Else
-
DoCmd.OpenForm "Form2"
-
End If
-
Do you have any suggestions better than this? thanks
Rosie
|  | Expert | | Join Date: Apr 2006 Location: Philadelphia
Posts: 5,214
| | | re: Can a listbox be used to pop up a form based on selection? Quote:
Originally Posted by imrosie Hi ADezii,
Yes, you got it. They're two different forms gathering different info (but each will store into the Payments table). The listbox is called 'paymnt'.
I'm thinking of putting this behind a cmd button... - If Me.MyListBox.Value = 1 Then
-
DoCmd.OpenForm "Form1"
-
Else
-
DoCmd.OpenForm "Form2"
-
End If
-
Do you have any suggestions better than this? thanks
Rosie Place either 1 of the following code blocks in the AfterDate() Event of the List Box. Which block you use depends on whether the List Box contains 1 or 2 Columns: -
Private Sub paymnt_AfterUpdate()
-
'For a Single Column List Box
-
Select Case Me![paymnt]
-
Case "Check"
-
DoCmd.OpenForm "Form1"
-
Case "Credit Card"
-
DoCmd.OpenForm "Form2"
-
Case Else
-
End Select
-
-
'For a 2 Column List Box (1st Key Column hidden)
-
Select Case Me![paymnt].Column(1)
-
Case "Check"
-
DoCmd.OpenForm "Form1"
-
Case "Credit Card"
-
DoCmd.OpenForm "Form2"
-
Case Else
-
End Select
-
End Sub
-
|  | Familiar Sight | | Join Date: May 2007
Posts: 222
| | | re: Can a listbox be used to pop up a form based on selection? Quote:
Originally Posted by ADezii Place either 1 of the following code blocks in the AfterDate() Event of the List Box. Which block you use depends on whether the List Box contains 1 or 2 Columns: -
Private Sub paymnt_AfterUpdate()
-
'For a Single Column List Box
-
Select Case Me![paymnt]
-
Case "Check"
-
DoCmd.OpenForm "Form1"
-
Case "Credit Card"
-
DoCmd.OpenForm "Form2"
-
Case Else
-
End Select
-
-
'For a 2 Column List Box (1st Key Column hidden)
-
Select Case Me![paymnt].Column(1)
-
Case "Check"
-
DoCmd.OpenForm "Form1"
-
Case "Credit Card"
-
DoCmd.OpenForm "Form2"
-
Case Else
-
End Select
-
End Sub
-
Thanks so much ADezii,
My listbox has only 1 column. So I'll use the first one..
thanks again,
Rosie
|  | Expert | | Join Date: Apr 2006 Location: Philadelphia
Posts: 5,214
| | | re: Can a listbox be used to pop up a form based on selection? Quote:
Originally Posted by imrosie Thanks so much ADezii,
My listbox has only 1 column. So I'll use the first one..
thanks again,
Rosie Anytime, Rosie. we're always here to help if needed.
|  | Familiar Sight | | Join Date: May 2007
Posts: 222
| | | re: Can a listbox be used to pop up a form based on selection? Quote:
Originally Posted by ADezii Anytime, Rosie. we're always here to help if needed. ADezii,
The compiler(runtime error) its complaining about the dot{.} or exclamation, or parenthesis in the first line of the Select statement.
I've tried the following:
1.) "Select Case Me.paymnt
2.) "Select Case Me.[paymnt]
any ideas?
Rosie
|  | Expert | | Join Date: Apr 2006 Location: Philadelphia
Posts: 5,214
| | | re: Can a listbox be used to pop up a form based on selection? Quote:
Originally Posted by imrosie ADezii,
The compiler(runtime error) its complaining about the dot{.} or exclamation, or parenthesis in the first line of the Select statement.
I've tried the following:
1.) "Select Case Me.paymnt
2.) "Select Case Me.[paymnt]
any ideas?
Rosie - The code as listed in Post #5 is correct:
-
Select Case Me![paymnt]
-
Case "Check"
-
DoCmd.OpenForm "Form1"
-
Case "Credit Card"
-
DoCmd.OpenForm "Form2"
-
Case Else
-
End Select
-
- Are you executing the code in the AfterUpdate() Event of paymnt?
- Is paymnt the correct Name for the List Box?
|  | Similar Microsoft Access / VBA bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,419 network members.
|