Results 1 to 7 of 7
  1. #1
    Join Date
    May 2002
    Posts
    395

    Unanswered: Passing in variables "argument not optional"

    I can't understand why I'm getting the error message above. I pass in same # and in the same order of variables to calling function and declared the variables in the function that is being called.
    Could someone see where is the problem at.
    Thank you much!!


    Private Sub inspec_id_Change()
    On Error GoTo Err_inspec_id_Change
    Dim work_ord_num As String, work_ord_line_num As String

    If Len(Trim(Me!inspec_id.Text)) = inspec_id_length Then
    If IsNull(Me!work_ord_num) Then
    work_ord_num = ""
    work_ord_line_num = ""
    Else
    work_ord_num = Me!work_ord_num
    End If
    Call show_next_sample(Me!inspec_id.Text, work_ord_num, work_ord_line_num)
    ''' called show_next_sample

    End If

    Exit_inspec_id_Change:
    'If ret_val <> 0 Then rs_get_next_sample.Close
    'Set get_next_sample = Nothing
    Exit Sub

    Err_inspec_id_Change:
    MsgBox Err.Description
    Resume Exit_inspec_id_Change
    End Sub

    Sub show_next_sample(inspec_id As Integer, work_ord_num As String, work_ord_line_num As String)
    ''''Error message occurred here

    On Error GoTo Err_show_next_sample
    Dim ret_val As Byte, HeadStr As String, stDocName As String, stLinkCriteria As String
    Dim get_next_sample As New ADODB.Command, rs_get_next_sample As New ADODB.Recordset

    .
    .
    .
    End Sub

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    be pedantic^2:

    dim some vars as integer, string, string

    set your dimmed vars using
    cint(inspec_id)
    cstr(work_ord_num)
    cstr(work_ord_line_num)

    and call using your new vars.

    ...maybe msgbox the vars and their non-cxxx equivalents to see what happened.

    is it a null work_ord_line_num ??

    izy
    Last edited by izyrider; 06-02-03 at 18:13.

  3. #3
    Join Date
    May 2002
    Posts
    395
    Originally posted by izyrider
    be pedantic^2:

    dim some vars as integer, string, string

    set your dimmed vars using
    cint(inspec_id)
    cstr(work_ord_num)
    cstr(work_ord_line_num)

    and call using your new vars.

    ...maybe msgbox the vars and their non-cxxx equivalents to see what happened.

    is it a null work_ord_line_num ??

    izy
    Hello Izy,

    work_ord_line_num contains a null value when passed in but returns an output value from called function. I think I got it working.
    Thanks for your reply and help.

    I'm having trouble with "subscript out of range" error that is related to the arrays. It pops up periodically. Could you give me some explanation on this error?

    Thanks again!

  4. #4
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    be pedantic^2
    Pedantic squared - wow, what a concept!

    I had to look up in an online dictionary just to see what pedantic even means. And to save some others from the task it loosely means to pay a lot of attention to the details.
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

  5. #5
    Join Date
    May 2002
    Posts
    395
    Originally posted by Bullschmidt
    Pedantic squared - wow, what a concept!

    I had to look up in an online dictionary just to see what pedantic even means. And to save some others from the task it loosely means to pay a lot of attention to the details.
    Glad to know there are intelligent people out there. Thanks for the definition.

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    we've wandered off-topic a touch, but my intended usage was "pay obsessive attention to the details" as in dimming a string and cstr-ing a known-to-be-string into it (for debugging only!!!). i've wasted too many debugging hours with known-to-beees that weren't!


    back at the ranch...

    alicejwz: your out-of-range is still pending. there's no mention of arrays elsewhere in your post - got any details?

    izy

  7. #7
    Join Date
    May 2002
    Posts
    395

    subscript out of range

    Originally posted by izyrider
    we've wandered off-topic a touch, but my intended usage was "pay obsessive attention to the details" as in dimming a string and cstr-ing a known-to-be-string into it (for debugging only!!!). i've wasted too many debugging hours with known-to-beees that weren't!


    back at the ranch...

    alicejwz: your out-of-range is still pending. there's no mention of arrays elsewhere in your post - got any details?

    izy
    Good Morning,

    Thanks for wanting to help me with the subscript out of range error.
    The subscript out of range only appeared once awhile and I can't see what caused it. I would appreciate any advice you may have.

    Thank you!

    Here is my code:

    Option Compare Database
    Option Explicit
    Dim field_list() As String
    Dim display_fields() As String

    Const field_list_length As Integer = 25


    Public Sub Form_Open(Cancel As Integer)

    Screen.MousePointer = 11

    Call load_const

    Me!shipping_sched_list_subform.SourceObject = "shipping_sched_list"
    ReDim display_fields(field_list_length - 1)
    ReDim field_list(field_list_length - 1)

    Call intialize_field_list
    Call prep_sched_input
    .
    .
    .
    End Sub


    Sub intialize_field_list()


    field_list(0) = "work_ord_num"
    field_list(1) = "cust_name"
    .
    .
    .
    field_list(23) = "shipped_qty_temp"

    End sub


    Sub prep_sched_input()
    On Error GoTo Err_prep_sched_input

    Call initialize_display_fields
    display_fields(0) = "work_ord_num"
    display_fields(1) = "cust_name"
    .
    .
    .
    display_fields(17) = "work_ord_line_num"

    Call set_columns
    Me!shipping_sched_list_subform.Locked = True

    Exit_prep_sched_input:
    Exit Sub

    ''''**** sometimes subscript out of range occurred here
    Err_prep_sched_input:
    MsgBox Err.Description
    Resume Exit_prep_sched_input

    End Sub



    Sub initialize_display_fields()
    Dim i As Integer
    ReDim display_fields(field_list_length - 1)

    For i = 0 To field_list_length - 1
    '''''' Error occurred here
    '''' display_fields(i)=<Subscript out of range>

    Next
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •