Hi all,
Is there a way to make a case select statement dependent on what form is open? I have an address form to add addresses and then insert into a many to many table two fields from that form. See attached code below. The form I want to use is dependent on another form and I could use this same thing with different forms similar to the one in question.
I am wondering about maybe something like:Code:Private Sub CboEmailType_AfterUpdate() If Me.NewRecord Then DoCmd.SetWarnings False DoCmd.RunSQL "INSERT INTO Person2EmailTbl (PersonID, EmailID) " & _ "VALUES (" & CboPerson & ", " & EmailID & ")" DoCmd.SetWarnings True End If Forms!PersonFrm.Refresh End Sub
SELECT CASE
Case1
If Me.NewRecord and if FormName thenEnd Case
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO Person2EmailTbl (PersonID, EmailID) " & _
"VALUES (" & CboPerson & ", " & EmailID & ")"
DoCmd.SetWarnings True
Case 2
If Me.NewRecord and if FormName thenDoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO Person2EmailTbl (CompanyID, EmailID) " & _
"VALUES (" & CboCompany & ", " & EmailID & ")"
DoCmd.SetWarnings True
End If
Somehting like that? Is that even possible?