Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error 2757

Status
Not open for further replies.

wdu94

Programmer
Aug 15, 2001
61
US
Hello,

I got run-time error 2757 from my project.The main problem is: When I select item from combox "cboGetTerr", if the selecting item like " Women's department" that is not work and get run time error 2757, if the selecting item like" department of women" that works fine. But I don't know how to solve " ' " problem. Any suggestion?

Many Thanks.
Jing


The following are my codes:

Private Sub cboGetTerr_AfterUpdate()

Dim conn As New ADODB.Connection
Dim com As New ADODB.Command
Set conn = CurrentProject.Connection
Set com.ActiveConnection = conn

Dim ST1 As String, ST2 As String, ST3 As String, ST4 As String, sql As String
ST1 = "SELECT TAXI_TERR.MC_NUM FROM TAXI_TERR"
ST2 = "SELECT TAXI_TERR.CARRIER FROM TAXI_TERR ORDER BY CARRIER"
ST3 = "SELECT TAXI_TERR.DBA FROM TAXI_TERR WHERE NOT(DBA IS NULL) ORDER BY DBA"
ST4 = "SELECT TAXI_TERR.TERRITORY FROM TAXI_TERR ORDER BY TERRITORY"

Select Case cboSearchType
Case "MC #"
sql = "SELECT * FROM TAXI_TERR WHERE MC_NUM = '" & cboGetTerr.Value & "'"
Case "CARRIER"
' sql = "SELECT * FROM TAXI_TERR WHERE CARRIER LIKE '*" & cboGetTerr.Value & "*'"
sql = "SELECT * FROM TAXI_TERR WHERE CARRIER = '" & cboGetTerr.Value & "'"
Case "DBA"
sql = "SELECT * FROM TAXI_TERR WHERE DBA = '" & cboGetTerr.Value & "'"
Case "Territory"
sql = "SELECT * FROM TAXI_TERR WHERE TERRITORY = '" & cboGetTerr.Value & "'"
End Select

Me.RecordSource = sql

Me.Requery

End Sub

*****************
When I changed "sql" to this way still not work:

Select Case cboSearchType
Case "MC #"
sql = "SELECT * FROM TAXI_TERR WHERE MC_NUM = """ & cboGetTerr.Value & """"
Case "CARRIER"
' sql = "SELECT * FROM TAXI_TERR WHERE CARRIER LIKE '*" & cboGetTerr.Value & "*'"
sql = "SELECT * FROM TAXI_TERR WHERE CARRIER = """ & cboGetTerr.Value & """"
Case "DBA"
sql = "SELECT * FROM TAXI_TERR WHERE DBA = """ & cboGetTerr.Value & """"
Case "Territory"
sql = "SELECT * FROM TAXI_TERR WHERE TERRITORY = """ & cboGetTerr.Value & """"
End Select






 
You have this:

... WHERE MC_NUM = """ & cboGetTerr.Value & """"

Have you tried one of the following?

... WHERE MC_NUM = """ & cboGetTerr.Value & """

OR

... WHERE MC_NUM = """" & cboGetTerr.Value & """"

I thought that one of those would work. Jim Lunde
compugeeks@hotmail.com
Custom Application Development
 
Hi, jimmythegeek,

Still not work in the MS Access Porject. Just work in the ms access. I already test it before. Do you have any ideas?

Thanks again.

Jing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top