Results 1 to 4 of 4
  1. #1
    danny2000 is offline Novice
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    14

    'No value given for one or more required parameters' (error)

    I have no idea why I'm getting an error with the code below. It's basically an after update event on a combobox where I've incorporated the selected value into an sql string.



    I'm getting the error :
    'No value given for one or more required parameters'


    Any clues as to what this could be? Thanks



    Code:
    Private Sub Combo2_AfterUpdate()
    
    Dim rst As ADODB.Recordset
    
    Dim str1 As String
    
    Set rst = New ADODB.Recordset
    rst.CursorType = adOpenKeyset
    rst.LockType = adLockOptimistic
    
    
    box = Me.Combo2.Text
    
    str1 = "SELECT Description FROM Table1 WHERE code = " & box
    
    'error occurs on the line below?
    rst.Open str1, CurrentProject.Connection, , , adcmttext
    
    Me.Text0.Value = rst.Fields(0)

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If [code] is a text field then try:
    str1 = "SELECT Description FROM Table1 WHERE code = '" & Me.Combo2 & "'"

  3. #3
    danny2000 is offline Novice
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    14
    Quote Originally Posted by RuralGuy View Post
    If [code] is a text field then try:
    str1 = "SELECT Description FROM Table1 WHERE code = '" & Me.Combo2 & "'"
    Thank you. That worked perfectly.
    I'm not sure I understand why though? How does this method work over the previous method I used? Is it the ' ' around the criteria that makes the difference?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Yes! In this case the string value must be surrounded with quotes.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error: Object Required
    By compooper in forum Programming
    Replies: 6
    Last Post: 06-22-2011, 07:52 AM
  2. Object Required Error.
    By Robeen in forum Forms
    Replies: 1
    Last Post: 03-28-2011, 10:30 AM
  3. Run-time error '424': Object required
    By cowboy in forum Programming
    Replies: 18
    Last Post: 07-07-2010, 03:32 PM
  4. Why am I getting error: too few parameters?
    By cowboy in forum Programming
    Replies: 3
    Last Post: 03-24-2010, 10:13 AM
  5. Replies: 0
    Last Post: 02-15-2007, 03:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums