delete a record from a form and its subform

H

hngo

Hi,

I has follow the code as per the answer by Wayne Morgan on the 18/3/2005 for
the same topic. However i have got the following error

Syntax error (missing operator) in query expression 'conveyor_id=38DR55'.

My code is as follow:

strsql = "DELETE * FROM TBL_CV_GEARBOX WHERE conveyor_id=" & Me.Equip_Id
CurrentDb.Execute strsql, dbfailonerror


many thanks in advance
 
A

Allen Browne

You need extra quotes if conveyor_id is a Text type field (not a number
type):

strsql = "DELETE * FROM TBL_CV_GEARBOX WHERE conveyor_id = """ & Me.Equip_Id
& """;"
 
H

hngo

Hi allen,

I now got an error message "too few parameters. expected 1."
The record in the subform table is empty ie no record. Is there any way we
can check to see whether or not the record is exist before run the query.
 
A

Allen Browne

When Access asks for a parameter, it means that one of the names does not
resolve to a field name. Check that the field name is correct.

For example, if the field is actually named "conveyer id" with a space,
include the space and place square brackets around the name:

"DELETE * FROM TBL_CV_GEARBOX WHERE [conveyor id] = """ & Me.Equip_Id &
""";"
 
H

hngo

thanks allen it works now

Allen Browne said:
When Access asks for a parameter, it means that one of the names does not
resolve to a field name. Check that the field name is correct.

For example, if the field is actually named "conveyer id" with a space,
include the space and place square brackets around the name:

"DELETE * FROM TBL_CV_GEARBOX WHERE [conveyor id] = """ & Me.Equip_Id &
""";"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

hngo said:
I now got an error message "too few parameters. expected 1."
The record in the subform table is empty ie no record. Is there any way
we
can check to see whether or not the record is exist before run the query.
 
Top