Parameter Error (1 Viewer)

Wayne

Crazy Canuck
Local time
Yesterday, 19:12
Joined
Nov 4, 2012
Messages
176
I set up a delete button on a form, that has five linked subforms. Here is the code I used:

Code:
Private Sub btnContinueDelete_Click()

    On Error GoTo Err_btnContinueDelete_Click

    Dim strPathPassword As String
    Dim db As DAO.Database
    Dim strQryDetails As String
    Dim strQryNotes As String
    Dim strQryDocs As String
    Dim strQryPix As String
    Dim strQryAssign As String

    'Create the string for the Password Check
    strPathPassword = DLookup("[DeletePassword]", "tblSysConfig", "[CompanyName] = '" & [Forms]![frmOrders]![CompanyName] & "'")
    
    'Create the strings for deleting the various child records
    strQryDetails = "DELETE * FROM [tblOrderDetails] WHERE [OrderNumber] =" & [Forms]![frmOrders]![OrderNumber]
    strQryNotes = "DELETE * FROM [tblOrdersNotes] WHERE [OrderNumber] =" & [Forms]![frmOrders]![OrderNumber]
    strQryDocs = "DELETE * FROM [tblDocuments] WHERE [OrderNumber] =" & [Forms]![frmOrders]![OrderNumber]
    strQryPix = "DELETE * FROM [tblJobPix] WHERE [OrderNumber] =" & [Forms]![frmOrders]![OrderNumber]
    strQryAssign = "DELETE * FROM [tblOrdersAssign] WHERE [OrderNumber] =" & [Forms]![frmOrders]![OrderNumber]
    
    If Me.txtPasswordDelete = strPathPassword Then
        Set db = CurrentDb
        'Delete the child records first
        CurrentDb.Execute strQryDetails, dbFailOnError
        CurrentDb.Execute strQryNotes, dbFailOnError
        CurrentDb.Execute strQryDocs, dbFailOnError
        CurrentDb.Execute strQryPix, dbFailOnError
        CurrentDb.Execute strQryAssign, dbFailOnError
        'Delete the parent record
        DoCmd.Close acForm, "frmPasswordDelete", acSaveNo
        DoCmd.RunCommand acCmdDeleteRecord
       MsgBox "This record, and all related records have been deleted.", vbInformation, "Success!"
    Else
        MsgBox "The password you entered is incorrect.", vbInformation, "Try Again"
        Exit Sub
    End If
    
    Set db = Nothing
    
Exit_btnContinueDelete_Click:
    Exit Sub
    
Err_btnContinueDelete_Click:
    MsgBox Err.Description, vbInformation, "Error!"
    Resume Exit_btnContinueDelete_Click
    
    
End Sub

I didn't use the cascading delete feature in the relationships set-up because then it would be too easy for someone to delete things. I set it up so a password has to be entered in order to delete anything, however, I get an error message that says "Too few parameters. Expected: 1". I have checked and re-checked, and all field and table names are spelled correctly.

Can anyone shed some light on this? Any ides would be appreciated.

Wayne
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 18:12
Joined
Feb 28, 2001
Messages
27,138
Normally, if you get an error, it offers you a Debug option. If you click Debug, it takes you to the line that fails. Did you do that and if so, which line was it?
 

vba_php

Forum Troll
Local time
Yesterday, 18:12
Joined
Oct 6, 2019
Messages
2,880
I have checked and re-checked, and all field and table names are spelled correctly.
that may be, but what about the all the form controls you are referencing in your queries? like the lines that contain =form!formName!ControlName? are you sure all those controls exist? also, try changing this:
Code:
strPathPassword = DLookup("[DeletePassword]", "tblSysConfig", "[CompanyName] = '" & [Forms]![frmOrders]![CompanyName] & "'")
to this:
Code:
strPathPassword = DLookup("DeletePassword", "tblSysConfig", "[CompanyName] = '" & [Forms]![frmOrders]![CompanyName] & "'")
 

vba_php

Forum Troll
Local time
Yesterday, 18:12
Joined
Oct 6, 2019
Messages
2,880
that's a dynamic page, guy:
Code:
codes.php?title=execqry
did you write that website? do you know PHP? well ok, maybe not dynamic, but using GET at the very least.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:12
Joined
Oct 29, 2018
Messages
21,453
that's a dynamic page, guy:
Code:
codes.php?title=execqry
did you write that website? do you know PHP? well ok, maybe not dynamic, but using GET at the very least.

It used to be a classic asp site, but I had to convert it to php when the host provider was changed. I only know a little bit of php.
 

Users who are viewing this thread

Top Bottom