Results 1 to 7 of 7

Thread: No Value ERROR

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780

    No Value ERROR

    hey i have this code
    VB Code:
    1. If Trs.State = adStateClosed Then
    2.     Trs.Open "SELECT Testble.IDNum, tblMachines.machines_desc FROM Testble, tblMachines", DBConn, adOpenDynamic, adLockOptimistic
    3.     Call Display(0)
    4.     Trs.MoveFirst

    and i get an error that says that
    "No Value given for one or more of the parameters"

    then debugger points to this line
    VB Code:
    1. Trs.Open "SELECT Testble.IDNum, tblMachines.machines_desc FROM Testble, tblMachines", DBConn, adOpenDynamic, adLockOptimistic

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    You are selecting data from two tables and yet you don't show how the tables are related.

    You need a JOIN clause or a WHERE clause that links the two together.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    ok cool, how do i do that?

    Trs.Open "SELECT Testble.IDNum, tblMachines.machines_desc FROM Testble, tblMachines JOIN Testble, tblMachines", DBConn, adOpenDynamic, adLockOptimistic

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    See the second top thread for hints on sql statements, joins etc.

    Trs.Open "SELECT Testble.IDNum, tblMachines.machines_desc FROM Testble, tblMachines", DBConn, adOpenDynamic, adLockOptimistic, adCmdText
    Bit in red missing.
    Also you should check that both table.field names exist, and are spelt correctly.
    The query should run, but would give you a cartesian result (ie everything in the one table against everything in the other table)

    Use a left join on at least one field that is the same in both tables, something like the following in the from clause.
    Code:
    Testble left join tblMachines on Testble.IDNum=tblMachines.IDNumID

    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    thnax for the help. this is the code that i used.

    VB Code:
    1. Private Sub Form_Load()
    2. Me.MousePointer = 11
    3. If Trs.State = adStateClosed Then
    4.     Trs.Open "SELECT Testble.IDNum, tblMachines.machines_desc FROM Testble LEFT JOIN tblMachines on Testble.IDNum=tblMachines.IDNumID", DBConn, adOpenDynamic, adLockOptimistic, adCmdText
    5.     Call display(0)
    6.     Trs.MoveFirst
    7. Else
    8.     Call display(1)
    9. End If
    10. Me.MousePointer = 0
    11. End Sub
    i still get the same error. is there something else that i am missing? thnax for your response on both of my threads

  6. #6
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    Originally posted by Dubya007
    thnax for the help. this is the code that i used.
    VB Code:
    1. Private Sub Form_Load()
    2. Me.MousePointer = 11
    3. If Trs.State = adStateClosed Then
    4.     Trs.Open "SELECT Testble.IDNum, tblMachines.machines_desc FROM Testble LEFT JOIN tblMachines on Testble.IDNum=tblMachines.IDNumID", DBConn, adOpenDynamic, adLockOptimistic, adCmdText
    5.     Call display(0)
    6.     Trs.MoveFirst
    7. Else
    8.     Call display(1)
    9. End If
    10. Me.MousePointer = 0
    11. End Sub
    Ok... time to go to debugging basics.. I hope..

    Copy n paste the sql statement into Access Sql Builder (or whichever db you are using) to see whether it runs.
    If it doesn't run, it should have a more helpful pointer to the problem area (suggests a fieldname is incorrectly spelt, so it can't find it).
    Is dbconn open?
    Breakpoint the operation and step through to see what variables are holding (look for nothings... and errors created).
    Separate out the .open statement like so:
    VB Code:
    1. Dim adoCon As ADODB.Connection
    2.     Dim adoRst As ADODB.Recordset
    3.    
    4.     adoCon.Open "Connection string"
    5.    
    6.     adoRst.LockType = adLockOptimistic
    7.     adoRst.CursorType = adOpenStatic
    8.     adoRst.ActiveConnection = adoCon
    9.     adoRst.Source = "Select * from testtble"
    10.     adoRst.Open Source, con, CursorType, LockType, options
    11.    
    12.     adoRst.Close
    13.     adoCon.Close
    14.     Set adoRst = Nothing
    15.     Set adoCon = Nothing
    Or something like that (use the intellisense drop downs?)

    Other than that, if its small enough, or zipped up, put it up onto a website (yours?) and paste a link in a post, we can look at it and advise better/fix it and send back so you can see how to amend it yourself.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    i got it thanx so much for the help, i went into Access made a query exactly how i wanted it and then copied the SQL statements into my program. here is the code that i used if you were wondering
    VB Code:
    1. Private Sub Form_Load()
    2. Dim sql As String
    3. Me.MousePointer = 11
    4. sql = "SELECT Testble.IDNum, tblMachines.machine_desc, Testble.NeedACheck," _
    5.        & "tblMachines.NeedsCheck, Testble.Date, tblMachines.deptId, Testble.Supervisor " _
    6.        & "FROM tblMachines INNER JOIN Testble ON tblMachines.id = Testble.IDNum"
    7. If Trs.State = adStateClosed Then
    8.     Trs.Open sql, DBConn, adOpenDynamic, adLockOptimistic, adCmdText
    9.     Trs.MoveFirst
    10.     Call display(0)
    11. Else
    12.    Call display(1)
    13. End If
    14. Me.MousePointer = 0
    15. 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
  •  



Click Here to Expand Forum to Full Width