Runtime Error 3061 when trying to execute Delete Query (1 Viewer)

Blazer Saga

Registered User.
Local time
Today, 10:27
Joined
Jan 22, 2007
Messages
12
Hi, I'm trying to creat a form that will delet the related data from a sub form when the check box on the main form that controls the display of the sub form is set to false.

I've had lot of exsperiance with C++ and some with Visual and C #, but this is the first access report I've writen that code more complex then "me.somefiled.visable = true"

The form is for an art sheet database and I anticipate that the salsemen entering the data will change the entries as tehy talk threw things with the customers. Since they will eatch probaly generate 30 or 40 of these entries a day I'm trying to cut down on the overhead of the database.

This is the code for the Delete Query:

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]![Order ID]));


And this is the AfterUpdate cod for the check box:

Private Sub Numbers_AfterUpdate()

If Me.Numbers = True Then
Me.Number_Catagory.Visible = True
Else
Me.Number_Catagory.Visible = False
CurrentDb.Execute "Delete Numbers Catagory", dbFailOnError
End If

End Sub

The post below seems like a similar problem, but I am unable to figure out how to aplie it to mine since the way the code is called it diferent, meaning I dont know how to call a DELETE query in that format. Tried, but kept getting sytax errors.

http://www.access-programmers.co.uk/forums/showthread.php?t=96322&highlight=runtime+error+3061
 

boblarson

Smeghead
Local time
Today, 07:27
Joined
Jan 12, 2001
Messages
32,059
Code:
Dim strSQL as String

strSQL = "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]![Order ID] & "));"

If Me.Numbers = True Then
Me.Number_Catagory.Visible = True
Else
Me.Number_Catagory.Visible = False
CurrentDb.Execute strSQL, dbFailOnError
End If
 

Blazer Saga

Registered User.
Local time
Today, 10:27
Joined
Jan 22, 2007
Messages
12
Thanks.

Missed the " & [Forms]![Art Sheet]![Order ID] & " part.

Works fine now.
 

Users who are viewing this thread

Top Bottom