Global Public Not In List event Argument not optional... (1 Viewer)

MackMan

Registered User.
Local time
Today, 15:30
Joined
Nov 25, 2014
Messages
174
I need some help with something I'm obviously doing wrong...

I have several forms where the user can input supplier details (which use the same table) so I'm trying to use a public function to do this.

However when I call the code, I get an "Argument Not Optional" message.

The public sub is... (which is option explicit)

Code:
 Public Sub gcboPayeeSelectNotInListEvent(NewData As String, Response As Integer)
 Dim intAnswer As Integer
Dim strSQL As String
 On Error GoTo cboPayeeSelectNotInList_Err
 intAnswer = MsgBox("The Payee " & Chr(34) & NewData & Chr(34) & " is not currently listed." & vbCrLf & "Would you like to add it now?", vbQuestion + vbYesNo, "Unrecognised Payee.")
 If intAnswer = vbYes Then
     strSQL = "INSERT INTO tbl_Payees([PayeeName]) " & _
              "VALUES ('" & NewData & "');"
    DoCmd.SetWarnings False
    DoCmd.RunSQL strSQL
    DoCmd.SetWarnings True
 
    MsgBox "The new Payee has been added to the list." & _
        " Please enter remaining information" & vbCrLf & _
        "before proceeding further" _
        , vbInformation, "More data required..."
       Response = acDataErrAdded
       DoCmd.OpenForm "frmPAYEESAddEdit", acNormal, , "Payeename= """ & Me.cboPayeeSelect.Text & """"
    Form_frmPAYEESAddEdit.Caption = "Add details for Payee : " & Me.cboPayeeSelect.Text
    Form_frmPAYEESAddEdit.lblTitle.Caption = "ADD PAYEE : " & Me.cboPayeeSelect.Text
     Else
      MsgBox "Please choose a Payee from the list." _
      , vbInformation, "Please choose..."
      Response = acDataErrContinue
    End If
 cboPayeeSelectNotInList_Exit:
    Exit Sub
 cboPayeeSelectNotInList_Err:
    MsgBox Err.Description, vbCritical, "Error"
     
Resume cboPayeeSelectNotInList_Exit
 End Sub
on the form that triggers the event is (also option explicit)
Code:
Private Sub cboPayeeSelect_NotInList(NewData As String, Response As Integer)
gcboPayeeSelectNotInListEvent
 End Sub
What's happened? I know I'm missing an optional arg, but don't know what it is?

As always, advise always appreciated.
 
Last edited:

MackMan

Registered User.
Local time
Today, 15:30
Joined
Nov 25, 2014
Messages
174
It's ok.. I omitted "NewData, Response" in the call handler.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:30
Joined
Aug 30, 2003
Messages
36,127
I assume that function is in a form module rather than a standard module? It would have to be with the usage of Me. That means you can only call it from that form.
 

MackMan

Registered User.
Local time
Today, 15:30
Joined
Nov 25, 2014
Messages
174
Hi PB, yes it was a form module. everything works perfectly as it should. I've not got so far as a standard module yet. I'll cross that bridge when I get to it, which in fact, I may have well just crashed upon. thanks for your reply. sorry about mine being so late.
 

Users who are viewing this thread

Top Bottom