[AccessD] Dynamically calling combobox_afterupdate from form_open event

Charlotte Foust charlotte.foust at gmail.com
Mon Mar 6 13:19:20 CST 2023


I haven't done this in a long time, so I have to ask why you're using a
"Step 2" In the line "For l = 0 To UBound(strArgs) Step 2"?   When I ran
into an issue with things like this, I added message boxes or line prints
to see what each result was so I could track down the exact location
throwing the error.  You aren't showing any error handling, so I am making
assumptions.  You need to at least see the result of the Eval() before you
try to call it.

Charlotte Foust
(916) 206-4336


On Mon, Mar 6, 2023 at 11:03 AM Ryan W <wrwehler at gmail.com> wrote:

> I have a form that takes openargs, the openargs are such as:
>
> cbxJobID|12345
>
>
> The key/pair set can be repeated.. the key is the control name, the other
> is the data to input into the control name
>
> my form open event is as such:
>
> Private Sub Form_Open(Cancel As Integer)
>     Dim l         As Long: l = 0
>     Dim strArgs() As String
>     If IsNull(Me.OpenArgs) Then Exit Sub
>
>     strArgs = Split(Me.OpenArgs, "|")
>     For l = 0 To UBound(strArgs) Step 2
>         Me(strArgs(l)) = strArgs(l + 1)
>         Call Eval(strArgs(l) & "_AfterUpdate")
>     Next l
>
> End Sub
>
>
>
> The problem I'm having is the "Call Eval()" part.  I get an error:
> "Run-Time error '2482':
> Cannot find name 'cbxJobID_AfterUpdate' you entered in the expression.
>
> However that exists.  I've tried making it a public sub, private sub,
> public or private function.
>
> None of it seems to work. Maybe it can't be a form level function/sub, has
> to be module level?
>
> The microsoft documentation under examples shows the method I'm using is
> supported:
>
> https://learn.microsoft.com/en-us/office/vba/api/access.application.eval
>
>
> The following example assumes that you have a series of 50 functions
> defined as A1, A2, and so on. This example uses the *Eval* function to call
> each function in the series.
> Sub CallSeries()
>
>  Dim intI As Integer
>
>  For intI = 1 To 50
>  Eval("A" & intI & "()")
>  Next intI
>
> End Sub
>
>
> So, something is missing here... can anyone clue me in?
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


More information about the AccessD mailing list