var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
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)
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,
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.
Dupe post I'm afraid DC
Perhaps a mod could clean up?
ur codings are working excelent.