Connecting Tech Pros Worldwide Forums | Help | Site Map

Can a listbox be used to pop up a form based on selection?

imrosie's Avatar
Familiar Sight
 
Join Date: May 2007
Posts: 222
#1: Aug 2 '07
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

ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,214
#2: Aug 7 '07

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.
imrosie's Avatar
Familiar Sight
 
Join Date: May 2007
Posts: 222
#3: Aug 7 '07

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...
Expand|Select|Wrap|Line Numbers
  1. If Me.MyListBox.Value = 1 Then
  2.  DoCmd.OpenForm "Form1"
  3. Else
  4.  DoCmd.OpenForm "Form2"
  5. End If
  6.  
Do you have any suggestions better than this? thanks

Rosie
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,214
#4: Aug 7 '07

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...

Expand|Select|Wrap|Line Numbers
  1. If Me.MyListBox.Value = 1 Then
  2.  DoCmd.OpenForm "Form1"
  3. Else
  4.  DoCmd.OpenForm "Form2"
  5. End If
  6.  
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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub paymnt_AfterUpdate()
  2. 'For a Single Column List Box
  3. Select Case Me![paymnt]
  4.   Case "Check"
  5.     DoCmd.OpenForm "Form1"
  6.   Case "Credit Card"
  7.     DoCmd.OpenForm "Form2"
  8.   Case Else
  9. End Select
  10.  
  11. 'For a 2 Column List Box (1st Key Column hidden)
  12. Select Case Me![paymnt].Column(1)
  13.   Case "Check"
  14.     DoCmd.OpenForm "Form1"
  15.   Case "Credit Card"
  16.     DoCmd.OpenForm "Form2"
  17.   Case Else
  18. End Select
  19. End Sub
  20.  
imrosie's Avatar
Familiar Sight
 
Join Date: May 2007
Posts: 222
#5: Aug 8 '07

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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub paymnt_AfterUpdate()
  2. 'For a Single Column List Box
  3. Select Case Me![paymnt]
  4.   Case "Check"
  5.     DoCmd.OpenForm "Form1"
  6.   Case "Credit Card"
  7.     DoCmd.OpenForm "Form2"
  8.   Case Else
  9. End Select
  10.  
  11. 'For a 2 Column List Box (1st Key Column hidden)
  12. Select Case Me![paymnt].Column(1)
  13.   Case "Check"
  14.     DoCmd.OpenForm "Form1"
  15.   Case "Credit Card"
  16.     DoCmd.OpenForm "Form2"
  17.   Case Else
  18. End Select
  19. End Sub
  20.  

Thanks so much ADezii,

My listbox has only 1 column. So I'll use the first one..

thanks again,
Rosie
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,214
#6: Aug 8 '07

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.
imrosie's Avatar
Familiar Sight
 
Join Date: May 2007
Posts: 222
#7: Aug 8 '07

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.

Expand|Select|Wrap|Line Numbers
  1. Select Case Me![paymnt]
I've tried the following:

1.) "Select Case Me.paymnt
2.) "Select Case Me.[paymnt]
any ideas?

Rosie
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,214
#8: Aug 8 '07

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.

Expand|Select|Wrap|Line Numbers
  1. Select Case Me![paymnt]
I've tried the following:

1.) "Select Case Me.paymnt
2.) "Select Case Me.[paymnt]
any ideas?

Rosie

  1. The code as listed in Post #5 is correct:
    Expand|Select|Wrap|Line Numbers
    1. Select Case Me![paymnt]
    2.   Case "Check"
    3.     DoCmd.OpenForm "Form1"
    4.   Case "Credit Card"
    5.     DoCmd.OpenForm "Form2"
    6.   Case Else
    7. End Select
    8.  
  2. Are you executing the code in the AfterUpdate() Event of paymnt?
  3. Is paymnt the correct Name for the List Box?
Reply


Similar Microsoft Access / VBA bytes