![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I want to run a macro depending on what a user enters in a specific field. If a user enters a code (i.e., 1-A-CB939) that contains the letters "CB", I want to run macro1. Else, if a user enters a code (i.e., 9-B-ME483) containing the letters "ME" into the Code field, I want to run macro2. I already figured out the SQL part (Like "*CB*" or Like "*ME*"). I just need help with the IF/ELSE VBA syntax to accomplish what I explained above. Thank you very much in advance. |
#3
| |||
| |||
|
|
You don't need SQL, try the Instr VBA function in the After Update event of your text box (replace YourTextBox with the actual name of the text box): If InStr(Me.YourTextBox, "CA") Then * * DoCmd.RunMacro "macro1" ElseIf InStr(Me.YourTextBox, "ME") Then * * DoCmd.RunMacro "macro2" End If HTH "Joe Smith" <bucbarr... (AT) gmail (DOT) com> wrote in message news:a8d882da-d1d2-4b46-acd4-f761163a9f39 (AT) n32g2000prc (DOT) googlegroups.com... I want to run a macro depending on what a user enters in a specific field. If a user enters a code (i.e., 1-A-CB939) that contains the letters "CB", I want to run macro1. Else, if a user enters a code (i.e., 9-B-ME483) containing the letters "ME" into the Code field, I want to run macro2. I already figured out the SQL part (Like "*CB*" or Like "*ME*"). I just need help with the IF/ELSE VBA syntax to accomplish what I explained above. Thank you very much in advance.- Hide quoted text - - Show quoted text - |
![]() |
| Thread Tools | |
| Display Modes | |
| |