AndyTampa
Board Regular
- Joined
- Aug 14, 2011
- Messages
- 199
- Office Version
- 365
- 2016
- Platform
- Windows
I'm working on this function to validate dates. I've written the function to be called from certain CommandButtons and from another function. I want this function to ask for a proper FTD if it was called from the CommandButtons and ask for a proper PTD if it was called from the MTBalPTD function.
Answers I've found are beyond my understanding. I've tried ChatGPT and it keeps giving answers that don't work. Then it keeps trying workarounds that get exponentially longer the more it tries.
I'm trying to use Application.Caller. I've used it in If statements. I've used it in Case Select statements. I'm getting Type Mismatch errors, Error 2023, and Run-time error '424' Object Required all depending on the different variations I've tried.
This is the last variation I tried before my eyes shut down for the night.
This function already has so many variables, I was hoping to prevent adding one and if possible, getting rid of the one I added here. Can someone make this mud a little clearer?
Answers I've found are beyond my understanding. I've tried ChatGPT and it keeps giving answers that don't work. Then it keeps trying workarounds that get exponentially longer the more it tries.
I'm trying to use Application.Caller. I've used it in If statements. I've used it in Case Select statements. I'm getting Type Mismatch errors, Error 2023, and Run-time error '424' Object Required all depending on the different variations I've tried.
This is the last variation I tried before my eyes shut down for the night.
VBA Code:
Dim callerName As String ' What called this function?
callerName = Application.Caller
Select Case True
Case callerName Like "*MTBalPTD*"
promptType = "PTD"
Case callerName Like "CommandButton*"
promptType = "FTD"
Case Else
promptType = "date"
End Select
This function already has so many variables, I was hoping to prevent adding one and if possible, getting rid of the one I added here. Can someone make this mud a little clearer?