Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Nanded, India

    Unanswered: Whats Wrong With This Code ? - Urgent Help Pls.


    I placed a combo box named CboSearchItem (Based on a query receiving data from table Product_master) on form to select and bring the record onto the form. It works smoothly.

    But when data in field ProductName contains " mark, it produces following error 3075 :

    Syntax error in string in query expression "ProductName = "Hose White 3/4"'"

    When I replaced all " mark from the data field ProductName, it works fine.
    For example Product Name are as follows:

    Elbow 2 Way
    ABC Pipe 3"
    Shower Pipe 1 1/5 Meter

    Getting all the above record but not the second one because it contains " mark.

    I can not tell my client not to use " while entering the product name. There should be a solution.

    My full code is as follows:

    Dim db As DAO.Database
    Dim rst1 As DAO.Recordset
    Dim fld As DAO.Field

    Set rst1 = CurrentDb.OpenRecordset("Select * From Product_Master " & _
    "where Productname= " & """" & CboSearchItem & """") ‘ error is here….

    For Each fld In rst1.Fields
    Me(fld.Name) = rst1(fld.Name)
    Next fld

    Set rst1 = Nothing

    For-Next loop will bring recordset from table on to the form instead of writing whole bunch of every field names in code

    It runs well when there are no " mark in the data. But produces error 3075 when product name contains “ mark somewhere. I need it to read all the characters contained in the data fields ProductName.

    Your immediate help will be highly appreciated.

    With kind regards,

  2. #2
    Join Date
    Feb 2004
    Chicago, IL
    Do you have a primary key for the Product table? If so I would set up my combo box to have two columns in it. Your RowSource should select the Primary Key and also the Product Name. Then have the bound column of the Combo Box be 1. Then have the Column Widths be 0;2 (or some other number than 2 inches). The column width being 0 will hide the Primary key from the user. Then when you are searching for the product, the combobox will be equal to the Primary Key and not the Product Name.

    It may be easier if you use the Combo Box wizard.

  3. #3
    Join Date
    Feb 2004
    One Flump in One Place
    Dupe post I'm afraid DC

    Perhaps a mod could clean up?
    pootle flump
    ur codings are working excelent.

Posting Permissions

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