Thank you.
Try something like this in your Expense Type combo box (or list box) to
change the subform's SourceObject property. This is just aircode typed in
this news posting:
Sub cboExpenseType_AfterUpdate()
Select Case Me.cboExpenseType
Case "Expense 1"
Me.NameOfSubformControl.SourceObject = "Expense1"
Case "Expense 2"
Me.NameOfSubformControl.SourceObject = "Expense2"
' etc
End Select
End Sub
If all the field were the same, you could also create just 1 subform and use
code similar to above to chance the Recordsource property
Me.NameOfSubformControl.Recordsource = "Select * From tblExpense Where
ExpenseType = "'" & Me.cboExpenseType & "'""
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
<nybase...@gmail.com> wrote in message
news:a128213a-484e-450c...@i3g2000hsf.googlegroups.com...
But, now that I have that, can I ask to take it a bit further? When I
open the main form to a new record or I make a selection that is not
one of my cases, I want the subform control to open with a generic
subform. I have the subform created, and I inserted this case:
Case Is = Null (because it would not let me do Case Is Null)
I also want to say if it does not equal any of the cases, it will open
this generic subform. In this case I could usually use <>, but I hate
to have to list all the cases with <> in the code. So, my question
is, can I have it default to a form if the selection does not equal
one of my cases?
NOTE: I created this as a Private Sub and use a Call Code in the
form's OnOpen and OnCurrent because I have other code used there as
well.
Thank you again for everything.
I changed the code to (which I use a "Call DetermineSubForm code):
Private Sub DetermineSubForm()
If IsNull(Me.[ExpenseType]) Then
Me.SubMainChild.SourceObject = "subExpense3"
Else
Select Case Me.ExpenseType
Case "Expense1"
Me.SubMainChild.SourceObject = "subExpense1"
Case "Expense2"
Me.SubMainChild.SourceObject = "SubExpense2"
End Select
End If
End Sub
Thanks again.
If IsNull(MyValue) Then
'
Else
Select Case MyValue
Case
Case
End Select
End If
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
<nybase...@gmail.com> wrote in message
news:11b25f9e-f10b-4321...@j20g2000hsi.googlegroups.com...
The SELECT CASE statement allows the inclusion of CASE ELSE at the end to
handle any cases that weren't explicitly caught.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
<nybase...@gmail.com> wrote in message
news:98f20807-8cbd-44f5...@q39g2000hsf.googlegroups.com...