kbrooks
Still learning
- Local time
- Today, 17:00
- Joined
- May 15, 2001
- Messages
- 202
I've spent the last hour searching for threads I thought were related and patched together some code, which I know very little of.
Here's what I want. I have a form with only 3 fields, one of which is a combobox ("Type") with 3 options ("Charge", "Payment/Adjustment", "Balance Transfer") I have 3 popup forms that correspond to those options. I would like the corresponding popup form to open based on their selection from the Type box.
Here's what I've done:
1. Set the 3 secondary forms to popup and modal
2. Entered the following code in the AfterUpdate event of the Type field (don't laugh):
Private Sub Type_AfterUpdate()
Select Case Me("Type")
Case "Charges":
DoCmd.OpenForm "Charges", , , , , , Me
Case "Payment/Adjustment":
DoCmd.OpenForm "Payments", , , , , , Me
Case "Balance Transfer":
DoCmd.OpenForm "BalanceTransfers", , , , , , Me
End Select
End Sub
I kind of combined the answers on a few threads to come up with this code so it's possible it makes absolutely no sense. When I select a type from the Type field, I get a run-time message with the error "An expression you entered is the wrong data type for one of the arguments". And when I click Debug, it highlights the
DoCmd.OpenForm "Charges", , , , , , Me line. I'm sure it's just the first of many errors it came to.
Can someone please tell me what I did wrong, or if I'm going about it completely wrong?
Another question.....if I have a autonumber (ID) on the main form, and also an autonumber (ID) on each of the secondary forms, will doing this the way I'm attempting link these together? Or do I need to have an ID on the secondary form that corresponds to the one on the main form, and ALSO a autonumber to uniquely identify that record? (Each patient on the main form could have multiple charges, etc on the secondary form.)
Here's what I want. I have a form with only 3 fields, one of which is a combobox ("Type") with 3 options ("Charge", "Payment/Adjustment", "Balance Transfer") I have 3 popup forms that correspond to those options. I would like the corresponding popup form to open based on their selection from the Type box.
Here's what I've done:
1. Set the 3 secondary forms to popup and modal
2. Entered the following code in the AfterUpdate event of the Type field (don't laugh):
Private Sub Type_AfterUpdate()
Select Case Me("Type")
Case "Charges":
DoCmd.OpenForm "Charges", , , , , , Me
Case "Payment/Adjustment":
DoCmd.OpenForm "Payments", , , , , , Me
Case "Balance Transfer":
DoCmd.OpenForm "BalanceTransfers", , , , , , Me
End Select
End Sub
I kind of combined the answers on a few threads to come up with this code so it's possible it makes absolutely no sense. When I select a type from the Type field, I get a run-time message with the error "An expression you entered is the wrong data type for one of the arguments". And when I click Debug, it highlights the
DoCmd.OpenForm "Charges", , , , , , Me line. I'm sure it's just the first of many errors it came to.
Can someone please tell me what I did wrong, or if I'm going about it completely wrong?
Another question.....if I have a autonumber (ID) on the main form, and also an autonumber (ID) on each of the secondary forms, will doing this the way I'm attempting link these together? Or do I need to have an ID on the secondary form that corresponds to the one on the main form, and ALSO a autonumber to uniquely identify that record? (Each patient on the main form could have multiple charges, etc on the secondary form.)