Question : syntax error in FROM clause

I have programmed the following code on the change event of my combo box cboBund in access 2000
When I first open the form and use the combo it returns

syntax error in FROM clause

However if I OK the error and move on the code works perfectly. If I click on help it identifies error 3131 as the offending error however I can not trap the error with this code.

I cant work out why this code is returning the error.

Private Sub cboBund_Change()
Dim strTyped As String
Dim strSelect As String
Dim RS As Object

    strTyped = Nz(Me.cboBund.Text, "")
    If Len(strTyped) = 5 Then
        strSelect = "SELECT [bundNo] " & _
        "FROM [tblAllocMain] " & _
             "WHERE [bundNo] LIKE """ & strTyped & "*"" " & _
             "ORDER BY [bundNo];"
        cboBund.RowSource = strSelect
    End If
End Sub

Answer : syntax error in FROM clause

Is this an ADP you're using?
The only reasons I can think of this failing are:

" Direct non Jet data access (e.g. ADP - as Jet is perfectly happy with double quote as a text delimiter)
" Delimiter mark in the string (likely handled by Arthur's suggestion - then single quotes become the problem requiring Replace)
" tblAllocMain isn't a table but it itself has a problem in its source definition.

To my mind only the latter of these three could cause the error you're describing.
The concept you're employing is sound (as you're using the combo's Text property - hence its availability in the Change event).

I see you've declared
Dim RS As Object
though it isn't used.  Was the original intent to employ one of the alternate recordset methods like that demo'd in the ComboFilter at this Example's Page.
However as you cite Acc2000 then a recordset won't help you directly (such binding came in 2002).
Could be a useful test though - make sure you get the same error when opening a recordset with your SQL.  You really should.

Random Solutions  
 
programming4us programming4us