Results 1 to 7 of 7

Thread: There is an Error can you spot it?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    68

    Post

    There is an error in the code below which returns 'OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET'

    The error is due to the statusfield not being set but how do I set it?

    Any help would be appreciated

    Simon

    For Each maxfield In MAXData.Fields
    Count = Count + 1

    If maxfield.Name = "dload_status" Then
    strSQLstatus = "SELECT mmiss.mmiss_code" & " FROM mmiss" & "WHERE mmiss.mmiss_code =" & Chr(39) & maxfield.Value & Chr(59)
    frmSearch.mmissdatasource.RecordSource = strSQLstatus
    Set StatusCode = frmSearch.mmissdatasource.Recordset
    frmView.MAXData(Count) = statusfield.Value
    '****This line ERROR's **** ^^^^^^^^^'
    Else
    frmView.MAXData(Count) = maxfield.Value
    End If
    Next

  2. #2
    Lively Member Dr_Evil's Avatar
    Join Date
    Mar 2000
    Location
    Columbus, OH
    Posts
    105
    I'm guessing that you have declared statusfield as a field for this one..

    Try
    Code:
    Dim statusfield AS Field
    
    Set statusfield = NEW Field
    Dr_Evil
    Senior Programmer
    VS6 EE
    VS.NET EA

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    68
    The statusfield is defined as follows

    code:
    dim statusfield as ADODB.field

    and setting the statusfield as new doesn't help at all.

    any other suggestions?

  4. #4
    Lively Member Dr_Evil's Avatar
    Join Date
    Mar 2000
    Location
    Columbus, OH
    Posts
    105
    Post the complete code with declarations included, this will make it easier for me to see what is missing... Thanks
    Dr_Evil
    Senior Programmer
    VS6 EE
    VS.NET EA

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    68

    Thanks for your help.

    Function Search_PN()
    Dim strSQL As String
    Dim MAXData As ADODB.Recordset
    Dim maxfield As ADODB.field

    Dim strSQLstatus As String
    Dim StatusCode As ADODB.Recordset
    Dim statusfield As ADODB.field

    'Set statusfield = New field

    Dim Count As Integer
    Count = -1

    strSQL = "SELECT uzdload.dload_item, uzdload.dload_descext, uzdload.dload_drawiss, uzdload.dload_striss, uzdload.dload_status, uzdload.dload_stitem, uzdload.dload_stiss" & " FROM uzdload" & " WHERE uzdload.dload_item = " & Chr(39) & frmSearch.DataComboPN.Text & Chr(39) & Chr(59)

    'Identifies which ADO connection is being used for SQL.
    frmSearch.maxdatasource.RecordSource = strSQL
    Set MAXData = frmSearch.maxdatasource.Recordset





    For Each maxfield In MAXData.Fields
    Count = Count + 1

    If maxfield.Name = "dload_status" Then
    strSQLstatus = "SELECT mmiss.mmiss_code" & " FROM mmiss" & " WHERE mmiss.mmiss_code =" & Chr(39) & maxfield.Value & Chr(39) & Chr(59)
    frmSearch.mmissdatasource.RecordSource = strSQLstatus
    Set StatusCode = frmSearch.mmissdatasource.Recordset
    frmView.MAXData(Count) = statusfield.Value
    Else
    frmView.MAXData(Count) = maxfield.Value
    End If
    Next

    MAXData.Close
    Set MAXData = Nothing

    End Function

  6. #6
    Lively Member Dr_Evil's Avatar
    Join Date
    Mar 2000
    Location
    Columbus, OH
    Posts
    105
    Ok, before you use the recordset objects, "MAXData, and StatusCode", and the Field Objects, "statusfield and max field" you need to set them.

    Code:
    Set MAXData = New ADODB.Recordset
    Set StatusCode = New ADODB.Recordset
    
    Set statusfield = New ADODB.Field
    Set maxfield = New ADODB.Field
    Hope this helps...
    Dr_Evil
    Senior Programmer
    VS6 EE
    VS.NET EA

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    68

    Thanks!

    Thanks for that!

    Why do I need to set them as new objects?

    When I submit or omit the NEW (word) I get a "METHOD or DATA MEMBER NOT FOUND" error

    Simon

Posting Permissions

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



Click Here to Expand Forum to Full Width