Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Burgas, Bulgaria
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete a record (Access 2000)

    I tried to build a code for deleting a record in my subform and i get the run time error 3075 missing ,] or item. Could you help me find the error in the folloiwng :
    Private Sub cartons_DblClick(Cancel As Integer)
    Dim strDelete As String
    strDelete = "DELETE [order details].OrderID, [order details].ProductID FROM [order details] " & _
    " WHERE ([order details].OrderID = Parent!OrderID AND [order details]!ProductID= Me!ProductID"
    DoCmd.RunSQL strDelete
    End Sub

    I also tried the following but again it gave me errors:

    strDelete = "DELETE [order details].OrderID, [order details].ProductID FROM [order details] " & _
    " WHERE ([order details].OrderID = " & Me.Parent!OrderID & " AND [order details].ProductID = " _
    & Me.ProductID & ";"

    CurrentDb.Execute strDelete, dbFailOnError
    You could see the error in my attachement, where by double clicking the control cartons the error appears

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Delete a record (Access 2000)

    You didn't attach a database.

    The first version is not valid, you cannot refer to Parent or Me within SQL.
    Both versions have an opening parenthesis ( after WHERE, but no closing parenthesis ). You don't really need the parentheses, so remove the (.

  3. #3
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Burgas, Bulgaria
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete a record (Access 2000)

    I have followed you advice,removed the patrenthesis but stuck with the

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Delete a record (Access 2000)

    If you want to refer to forms, you must use the correct names.

    1) The main form in your database is named FrmMain, not MainForm.
    2) When you refer to a subform, you must use the format Forms![Name of the main form]![Name of the subform], with the correct names substituted. The name of the subform must be that of the subform as a control on the mainform. This is not necessarily the same as the name of the subform in the database window. To find the name as a control, open the main form in design view and click once on the subform. The control name will be displayed in the Properties window and in the Formatting toolbar.
    In your database, this name is Forder details extended, so you must refer to the subform as Forms!FrmMain![Forder details extended].

    The SQL string becomes

    StrDelete = "DELETE OrderID FROM [order details] " & _
    "WHERE ([OrderID] = Forms!FrmMain!OrderID AND " & _
    "[ProductID]= Forms!FrmMain![Forder details extended]!ProductID)"

  5. #5
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Burgas, Bulgaria
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete a record (Access 2000)

    thank you so much for correcting me what i have overlooked.I have checked it quickly and it runs so good.

    THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Posting Permissions

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