Error 3464. Query worked fine when fields where number, but not with text. (1 Viewer)

Blazer Saga

Registered User.
Local time
Today, 04:15
Joined
Jan 22, 2007
Messages
12
Ok. I had an earlier post, http://www.access-programmers.co.uk/forums/showthread.php?t=121599, asking how to get a delete query to run in a form. At that time the field being used to look up the records was a number field. Recently I relised I will need to let them put letters into the field and so I switched the field to text all tables where it was referanced, and now the same query doesnt work. Instead I get an Error 3464. I have tested changing them back to numbers, and it will work again if I do so. Is there somthing in the folowing Query As String code that I need to change?

"DELETE [Numbers Catagory].[Order ID], [Numbers Catagory].* FROM [Art Sheets] INNER JOIN [Numbers Catagory] ON [Art Sheets].[Order ID] = [Numbers Catagory].[Order ID] WHERE ((([Numbers Catagory].[Order ID])=" & [Forms]![Art Sheet]![Txt Order ID] & "));

Where:
Art Sheet is the table the main form is based off of
Numbers Catagory is the table the sub form is based off of
Order ID is a field in Numbers Catagory not diplayed but selected in the sub form
Txt Order ID is a field displayed on Art Sheet and has the control source of Order ID from the Art Sheet table
Both Order IDs are type text with lengths of 8 and are linked in the relationships view, enforced, both cascades, and one to one.

The folloing seems to be a similar problem, but I am unable to figure out how to aply that to what I am doing.

http://www.access-programmers.co.uk/forums/showthread.php?t=46294&highlight=Error+3464+text+field
 

rborob

Registered User.
Local time
Today, 01:15
Joined
Jun 6, 2006
Messages
116
put single quotes around strings? outside of the double quotes?
 

boblarson

Smeghead
Local time
Today, 01:15
Joined
Jan 12, 2001
Messages
32,059
Add single quotes - see revised version:
Code:
"DELETE [Numbers Catagory].[Order ID], [Numbers Catagory].* FROM [Art Sheets] INNER JOIN [Numbers Catagory] ON [Art Sheets].[Order ID] = [Numbers Catagory].[Order ID] WHERE ((([Numbers Catagory].[Order ID])=[B]'[/B]" & [Forms]![Art Sheet]![Txt Order ID] & "[B]'[/B]));"
 

RuralGuy

AWF VIP
Local time
Today, 02:15
Joined
Jul 2, 2005
Messages
13,826
Text fields need to be surrounded with single or double quotes so try:
WHERE ((([Numbers Catagory].[Order ID])=" & Chr(34) & [Forms]![Art Sheet]![Txt Order ID] & Chr(34) & "));
...or
WHERE ((([Numbers Catagory].[Order ID])='" & [Forms]![Art Sheet]![Txt Order ID] & "'"));
 

MarkK

bit cruncher
Local time
Today, 01:15
Joined
Mar 17, 2004
Messages
8,181
But it's a delete query, so you don't need to call out all the fields in [Numbers Category]. What I'm curious about is does this delete (a) record(s) from both tables?
Code:
"DELETE FROM [Art Sheets] INNER JOIN [Numbers Catagory] " & _
  "ON [Art Sheets].[Order ID] = [Numbers Catagory].[Order ID] " & _
"WHERE [Numbers Catagory].[Order ID]) = '" & _
  [Forms]![Art Sheet]![Txt Order ID] & "';"
And if not you can use...
Code:
"DELETE FROM [Art Sheets] " & _
"WHERE [Order ID]) = '" & [Forms]![Art Sheet]![Txt Order ID] & "';"
 

Blazer Saga

Registered User.
Local time
Today, 04:15
Joined
Jan 22, 2007
Messages
12
Thank you guys, it was the missing 's, that part runs fine now.

As for what your asking Lagbolt, I don't think I understand what your asking, but what the call Im doing does it to delet a record of a subreport withing a partent report.

It is called from the parent report when the check box denoting weather the sub report is displayed is unchecked.

My database is ment to store artwork sheets and if the check box isn't checked for certain options I dont want to waist space on storing the sub options, so I delete the records.

If you want me to see if your code works to achive something else I'm more then happy to try it for you since the database is just a small dummy one im playing with untill the report is bug free.
 

MarkK

bit cruncher
Local time
Today, 01:15
Joined
Mar 17, 2004
Messages
8,181
I have three points.
1) A delete query does not need to specify field names.
Code:
DELETE field1, field2, field3 FROM Table
[COLOR="Green"]has the same effect and is more clearly expressed as[/COLOR]
DELETE FROM Table
2) I have not executed a delete query that contains an inner join. When you do this does it delete related records from both tables?
3) If the answer to 2) above is no, then there is no need to execute the inner join in the delete query either.

The conclusion being only that
Code:
"DELETE [Numbers Catagory].[Order ID], [Numbers Catagory].* " & _
"FROM [Art Sheets] INNER JOIN [Numbers Catagory] " & _
  "ON [Art Sheets].[Order ID] = [Numbers Catagory].[Order ID] " & _
"WHERE ((([Numbers Catagory].[Order ID])=" & _
  [Forms]![Art Sheet]![Txt Order ID] & "));
is far more difficult to understand and maintain than this
Code:
"DELETE FROM [Art Sheets] " & _
"WHERE [Order ID]) = '" & _
  [Forms]![Art Sheet]![Txt Order ID] & "';"
if they do the same work.
 

Users who are viewing this thread

Top Bottom