Run-time Error 5 "Invalid Procedure Call or Argument" (2 Viewers)

cursedeye

Registered User.
Local time
Today, 17:37
Joined
Oct 7, 2009
Messages
50
Also, one other thing that may have to do with it. Does each user have a DSN set up on their computer? If so, is it exactly the same as the others (did it get set up with the same ODBC driver?)? Which version of SQL Server are you connecting to and which ODBC driver are you using?

I don't think there is a problem in the Connection part, since they can view, change data without any issue.
 

cursedeye

Registered User.
Local time
Today, 17:37
Joined
Oct 7, 2009
Messages
50
Both computers don't have any missing reference...or at least got the same reference as I do.
 

vbaInet

AWF VIP
Local time
Today, 21:37
Joined
Jan 22, 2010
Messages
26,374
By the way, did you try the other variation I wrote?
Code:
If Len(strFilter) <> 0 And Nz(strcomp(strfilter, strOldFilter), 0) <> 0 Then
 

cursedeye

Registered User.
Local time
Today, 17:37
Joined
Oct 7, 2009
Messages
50
by the way, did you try the other variation i wrote?
Code:
if len(strfilter) <> 0 and nz(strcomp(strfilter, stroldfilter), 0) <> 0 then

omg! This is a miracle! It worked!
 

boblarson

Smeghead
Local time
Today, 13:37
Joined
Jan 12, 2001
Messages
32,059
I missed that the strComp function was being used. Good to see that worked and Kudos to vbaInet. One more reason we are glad to be graced by their presence. :)
 

cursedeye

Registered User.
Local time
Today, 17:37
Joined
Oct 7, 2009
Messages
50
Yea, you guys are amazing! Thanks for being so patient !

I almost gave up myself!

Do you know the reason why it worked on some computers but not on others?
 

vbaInet

AWF VIP
Local time
Today, 21:37
Joined
Jan 22, 2010
Messages
26,374
I'm unsure why it behaved that way, but in some other programming environments I have seen that kind of comparison fail, even though it is perfectly a legit comparison.

In what country are those other two machines that fail on that line? Could it be some sort of Locale or regional problem? I don't know.

But I'm glad this is resolved.
 

datAdrenaline

AWF VIP
Local time
Today, 15:37
Joined
Jun 23, 2008
Messages
697
>> Do you know the reason why it worked on some computers but not on others? <<

The comparison method that VBA uses is often indicated at the top of the Module with a statement that looks like this:

Option Compare Database

What that means is that text comparisons are based on the locale ID. I
*think* that is an Access wide setting (but I am short on time to verify
that), so one pc may have a different locale ID than the rest. If you do
not have an Option Compare compiler directive, VBA will use case-
sensitive comparisons.

To explicitly cause case-sensitive comparisons in a module ...
Option Compare Binary

To force a case-INsensitive comparison in a module ...
Option Compare Text

-----

Note ... this may have nothing to do with your issue, but if nothing else,
its good info to tuck away.
 

Charlene

New member
Local time
Today, 15:37
Joined
Dec 14, 2011
Messages
1
I have been having same issue copying from one server to another. I've found if you are using an .accdb frontend if you compact & repair on their machine it works fine. If you are using a .accde, I've remoted to the machine in question and created my .accde from the .accdb on their machine and copied it to production and the problem cleared up.
 

ABE86

New member
Local time
Today, 23:37
Joined
May 10, 2023
Messages
10
hello all.
this is my very first post o a forum, so please don't mind my lack of knowledge or my spelling mistakes.
i'm also a newbie in access development trying to wrap my head around vba.
i got stuck on this Run-time Error 5 "Invalid Procedure Call or Argument" for weeks.

i have a main form on which i have an object called box1 and some command buttons that changes the .sourceobject of box1 to some other additional forms, applying filters to them in most cases. the other two forms use a custom funtion called fLiveSearch to filter results in a listbox control and they both work well independently. but when i try to apply a filtre via vba from the main form, frmPersonal generates the above error.
debug mode highlights line 56 in the frmPersonal code, apparently doesn't like the me. reference in me.filteron, me.filter, me.txtSearch.value and so on... saying that the object is closed or does not exist. i've tryed to replace me. with form_frmPersonal and forms!frmPersonal, but i get some other errors. i'm guessing that the form set as sourceobject to the box1 control its not loaded therefore it cannot find the expression me.txtSearch.Value generating the invalid argument error. the error occurs only when i try to apply the filter via vba from the main form.

any idea on how i could get over it?
works on this form
Private Sub btnCursuriCatb_Click()
Me.Box1.SourceObject = "frmcursuri"
Me.Box1.Form.Filter = "tblCatCurs_ID=2"
Me.Box1.Form.FilterOn = True
Me.Box1.SetFocus
Me.Box1.Form.Requery
End Sub


doesn't on this one
Private Sub btnPersRES_Click()
Me.Box1.SourceObject = "frmPersonal"
Me.Box1.Form.Filter = "tblSubunitate_ID=1"
Me.Box1.Form.FilterOn = True
Me.Box1.SetFocus
Me.Box1.Form.Requery
End Sub
[ICODE]
 

ABE86

New member
Local time
Today, 23:37
Joined
May 10, 2023
Messages
10
hello all.
this is my very first post o a forum, so please don't mind my lack of knowledge or my spelling mistakes.
i'm also a newbie in access development trying to wrap my head around vba.
i got stuck on this Run-time Error 5 "Invalid Procedure Call or Argument" for weeks.

i have a main form on which i have an object called box1 and some command buttons that changes the .sourceobject of box1 to some other additional forms, applying filters to them in most cases. the other two forms use a custom funtion called fLiveSearch to filter results in a listbox control and they both work well independently. but when i try to apply a filtre via vba from the main form, frmPersonal generates the above error.
debug mode highlights line 56 in the frmPersonal code, apparently doesn't like the me. reference in me.filteron, me.filter, me.txtSearch.value and so on... saying that the object is closed or does not exist. i've tryed to replace me. with form_frmPersonal and forms!frmPersonal, but i get some other errors. i'm guessing that the form set as sourceobject to the box1 control its not loaded therefore it cannot find the expression me.txtSearch.Value generating the invalid argument error. the error occurs only when i try to apply the filter via vba from the main form.

any idea on how i could get over it?
works on this form
Private Sub btnCursuriCatb_Click()
Me.Box1.SourceObject = "frmcursuri"
Me.Box1.Form.Filter = "tblCatCurs_ID=2"
Me.Box1.Form.FilterOn = True
Me.Box1.SetFocus
Me.Box1.Form.Requery
End Sub


doesn't on this one
Private Sub btnPersRES_Click()
Me.Box1.SourceObject = "frmPersonal"
Me.Box1.Form.Filter = "tblSubunitate_ID=1"
Me.Box1.Form.FilterOn = True
Me.Box1.SetFocus
Me.Box1.Form.Requery
End Sub
[ICODE]
Code:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "Form_frmCursuri"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Compare Database
Option Explicit

Private blnSpace As Boolean

Private Sub btnClearFilter_Click()
On Error Resume Next
    Me.txtSearch.Value = ""
    txtSearch_Change
End Sub

Private Sub btnClearFilter_Enter()
    Me.txtSearch.Value = ""
    txtSearch_Change
End Sub

Private Sub lstItems_AfterUpdate()
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[ID] = " & Str(Nz(Me![lstItems], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Private Sub txtSearch_Change()
Dim strFullList       As String
Dim strFilteredList   As String

    If blnSpace = False Then
        Me.Refresh
        If Me.FilterOn = True Then
            strFullList = "SELECT tblCursuri.ID, tblCursuri.Denumire, tblCursuri.Descriere FROM tblCursuri WHERE " & Me.Filter & " ORDER BY tblCursuri.tblCatCurs_ID;"
            strFilteredList = "SELECT tblCursuri.ID, tblCursuri.Denumire, tblCursuri.Descriere FROM tblCursuri WHERE " & Me.Filter & " AND [Denumire] LIKE ""*" & Me.txtSearch.Value & _
                "*"" OR " & Me.Filter & " AND [Descriere] LIKE ""*" & Me.txtSearch.Value & "*"" ORDER BY tblCursuri.ID;"
        Else
            strFullList = "SELECT tblCursuri.ID, tblCursuri.Denumire, tblCursuri.Descriere FROM tblCursuri ORDER BY tblCursuri.tblCatCurs_ID;"
            strFilteredList = "SELECT tblCursuri.ID, tblCursuri.Denumire, tblCursuri.Descriere FROM tblCursuri WHERE [Denumire] LIKE ""*" & Me.txtSearch.Value & _
                "*"" OR [Descriere] LIKE ""*" & Me.txtSearch.Value & "*"" ORDER BY tblCursuri.ID;"
        End If
        fLiveSearch Me.txtSearch, Me.lstItems, strFullList, strFilteredList, Me.txtCount
    End If
End Sub

Private Sub txtSearch_KeyPress(KeyAscii As Integer)
    On Error GoTo err_handle
    If KeyAscii = 32 Then
        blnSpace = True
    Else
        blnSpace = False
    End If
    Exit Sub
err_handle:
    Select Case Err.Number
    Case Else
        MsgBox "An unexpected error has occurred: " & vbCrLf & Err.Description & _
            vbCrLf & "Error " & Err.Number & "(" & Erl & ")"
    End Select
End Sub

Private Sub txtSearch_GotFocus()
    On Error Resume Next
    If Me.txtSearch.Value = "(Cautare)" Then
        Me.txtSearch.Value = ""
    End If
End Sub

Private Sub txtSearch_LostFocus()
    On Error Resume Next
    If Me.txtSearch.Value = "" Then
        Me.txtSearch.Value = "(Cautare)"
    End If
End Sub

Private Sub Form_Current()
    txtSearch_Change
    lstItems.SetFocus
 End Sub
'------------------------------------------------------------
' btnEditCurs_Click
'
'------------------------------------------------------------
Private Sub btnEditCurs_Click()

    DoCmd.OpenForm "frmEditCursuri", acNormal, "", "[ID]=Forms![Accordion_MainMenu].Box1!ID", , acNormal

End Sub


'------------------------------------------------------------
' btnCatCursParticipanti_Click
'
'------------------------------------------------------------
Private Sub btnCatCursParticipanti_Click()

    DoCmd.OpenReport "rptCatCursParticipanti", acViewReport, "", "[tblCatCurs_ID]=Forms![Accordion_MainMenu].box1![tblCatCurs_ID]", acNormal

End Sub


'------------------------------------------------------------
' btnSerie_Click
'
'------------------------------------------------------------
Private Sub btnSerie_Click()

    DoCmd.OpenForm "frmSerieCurs", acNormal, "", "", acAdd, acNormal
    Forms!frmSerieCurs!tblCursuri_ID = Forms![accordion_mainmenu].Box1!ID

End Sub
 

ABE86

New member
Local time
Today, 23:37
Joined
May 10, 2023
Messages
10
hello all.
this is my very first post o a forum, so please don't mind my lack of knowledge or my spelling mistakes.
i'm also a newbie in access development trying to wrap my head around vba.
i got stuck on this Run-time Error 5 "Invalid Procedure Call or Argument" for weeks.

i have a main form on which i have an object called box1 and some command buttons that changes the .sourceobject of box1 to some other additional forms, applying filters to them in most cases. the other two forms use a custom funtion called fLiveSearch to filter results in a listbox control and they both work well independently. but when i try to apply a filtre via vba from the main form, frmPersonal generates the above error.
debug mode highlights line 56 in the frmPersonal code, apparently doesn't like the me. reference in me.filteron, me.filter, me.txtSearch.value and so on... saying that the object is closed or does not exist. i've tryed to replace me. with form_frmPersonal and forms!frmPersonal, but i get some other errors. i'm guessing that the form set as sourceobject to the box1 control its not loaded therefore it cannot find the expression me.txtSearch.Value generating the invalid argument error. the error occurs only when i try to apply the filter via vba from the main form.

any idea on how i could get over it?
works on this form
Private Sub btnCursuriCatb_Click()
Me.Box1.SourceObject = "frmcursuri"
Me.Box1.Form.Filter = "tblCatCurs_ID=2"
Me.Box1.Form.FilterOn = True
Me.Box1.SetFocus
Me.Box1.Form.Requery
End Sub


doesn't on this one
Private Sub btnPersRES_Click()
Me.Box1.SourceObject = "frmPersonal"
Me.Box1.Form.Filter = "tblSubunitate_ID=1"
Me.Box1.Form.FilterOn = True
Me.Box1.SetFocus
Me.Box1.Form.Requery
End Sub
[ICODE]
Code:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "Form_frmPersonal"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Compare Database
Option Explicit

Private blnSpace As Boolean

Private Sub CommandFirstRecord_Click()
    DoCmd.GoToRecord , "", acFirst
End Sub

Private Sub CommandPreviousRecord_Click()
    DoCmd.GoToRecord , "", acPrevious
End Sub

Private Sub CommandNextRecord_Click()
    DoCmd.GoToRecord , "", acNext
End Sub

Private Sub CommandLastRecord_Click()
    DoCmd.GoToRecord , "", acLast
End Sub

Private Sub btnClearFilter_Click()
On Error Resume Next
    Me.txtSearch.Value = ""
    txtSearch_Change
End Sub

Private Sub btnClearFilter_Enter()
    Me.txtSearch.Value = ""
    txtSearch_Change
End Sub

Private Sub lstItems_AfterUpdate()
    Dim rs As Object
    
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[ID] = " & Str(Nz(Me![lstItems], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Private Sub txtSearch_Change()
Dim strFullList       As String
Dim strFilteredList   As String
    
    If blnSpace = False Then
        Me.Refresh
        If Me.FilterOn = True Then
            strFullList = "SELECT qryPersonal.ID, [grad] & ' ' & [nume] & ' ' & [prenume] AS [Grad, nume si prenume] FROM qryPersonal WHERE " & Me.Filter & " ORDER BY qryPersonal.Nume, qryPersonal.Prenume;"
            strFilteredList = "SELECT qryPersonal.ID, [grad] & ' ' & [nume] & ' ' & [prenume] AS [Grad, nume si prenume] FROM qryPersonal WHERE " & Me.Filter & " AND [nume] LIKE ""*" & Me.txtSearch.Value & _
                "*"" OR " & Me.Filter & " AND [prenume] LIKE ""*" & Me.txtSearch.Value & "*"" ORDER BY qryPersonal.Nume, qryPersonal.Prenume;"
        Else
            strFullList = "SELECT qryPersonal.ID, [grad] & ' ' & [nume] & ' ' & [prenume] AS [Grad, nume si prenume] FROM qryPersonal ORDER BY qryPersonal.Nume, qryPersonal.Prenume;"
            strFilteredList = "SELECT qryPersonal.ID, [grad] & ' ' & [nume] & ' ' & [prenume] AS [Grad, nume si prenume] FROM qryPersonal WHERE [nume] LIKE ""*" & Me.txtSearch.Value & _
                "*"" OR [prenume] LIKE ""*" & Me.txtSearch.Value & "*"" ORDER BY qryPersonal.Nume, qryPersonal.Prenume;"
        End If
        fLiveSearch Me.txtSearch, Me.lstItems, strFullList, strFilteredList
    End If
End Sub

Private Sub txtSearch_KeyPress(KeyAscii As Integer)
    On Error GoTo err_handle
    If KeyAscii = 32 Then
        blnSpace = True
    Else
        blnSpace = False
    End If
    Exit Sub
err_handle:
    Select Case Err.Number
    Case Else
        MsgBox "An unexpected error has occurred: " & vbCrLf & Err.Description & _
            vbCrLf & "Error " & Err.Number & "(" & Erl & ")"
    End Select
End Sub

Private Sub txtSearch_GotFocus()
    On Error Resume Next
    If Me.txtSearch.Value = "(Cautare)" Then
        Me.txtSearch.Value = ""
    End If
End Sub

Private Sub txtSearch_LostFocus()
    On Error Resume Next
    If Me.txtSearch.Value = "" Then
        Me.txtSearch.Value = "(Cautare)"
    End If
End Sub

Private Sub Form_Current()
    txtSearch_Change
    lstItems.SetFocus
 End Sub

'------------------------------------------------------------
' btnAddRecord_Click
'
'------------------------------------------------------------
Private Sub btnAddRecord_Click()

    On Error Resume Next
    DoCmd.GoToRecord , "", acNewRec
    If (MacroError <> 0) Then
        Beep
        MsgBox MacroError.Description, vbOKOnly, ""
    End If

End Sub


'------------------------------------------------------------
' btnDeleteRecord_Click
'
'------------------------------------------------------------
Private Sub btnDeleteRecord_Click()

    On Error Resume Next
    DoCmd.GoToControl Screen.PreviousControl.Name
    Err.Clear
    If (Not Form.NewRecord) Then
        DoCmd.RunCommand acCmdDeleteRecord
    End If
    If (Form.NewRecord And Not Form.Dirty) Then
        Beep
    End If
    If (Form.NewRecord And Form.Dirty) Then
        DoCmd.RunCommand acCmdUndo
    End If
    If (MacroError <> 0) Then
        Beep
        MsgBox MacroError.Description, vbOKOnly, ""
    End If

End Sub


'------------------------------------------------------------
' tblGrad_ID_AfterUpdate
'
'------------------------------------------------------------
Private Sub tblGrad_ID_AfterUpdate()

    If (Eval("[Forms]![accordion_mainmenu].box1![tblGrad_ID] Between 1 And 7")) Then
        Forms![accordion_mainmenu].Box1!tblCatPersonal_ID = 1
    End If
    If (Eval("[Forms]![accordion_mainmenu].box1![tblGrad_ID] Between 8 And 12")) Then
        Forms![accordion_mainmenu].Box1!tblCatPersonal_ID = 2
    End If
    If (Eval("[Forms]![accordion_mainmenu].box1![tblGrad_ID] Between 13 And 17")) Then
        Forms![accordion_mainmenu].Box1!tblCatPersonal_ID = 3
    End If
    If (Forms![accordion_mainmenu].Box1!tblGrad_ID = 18) Then
        Forms![accordion_mainmenu].Box1!tblCatPersonal_ID = 4
    End If
    If (Forms![accordion_mainmenu].Box1!tblGrad_ID = 19) Then
        Forms![accordion_mainmenu].Box1!tblCatPersonal_ID = 5
    End If

End Sub


'------------------------------------------------------------
' tblSubunitate_ID_AfterUpdate
'
'------------------------------------------------------------
Private Sub tblSubunitate_ID_AfterUpdate()

    Forms![accordion_mainmenu].Box1!MutatDin = Date
    Beep
    MsgBox "Data la care a fost mutat la alta subunitate a fost setata la data curenta. Modificati daca este necesar!", vbInformation, "Data mutarii la alta subunitate"

End Sub


'------------------------------------------------------------
' Activ_AfterUpdate
'
'------------------------------------------------------------
Private Sub Activ_AfterUpdate()

    If (Forms![accordion_mainmenu].Box1!Activ = True) Then
        Forms![accordion_mainmenu].Box1!InactivDin = Null
    End If
    If (Eval("[Forms]![accordion_mainmenu].box1![Activ]=False And [Forms]![accordion_mainmenu].box1![InactivDin] Is Null")) Then
        Beep
        MsgBox "Data la care a incetat activitatea in cadrul ISU Mures a fost setata la data curenta. Modificati daca este necesar!", vbInformation, "Data la care a incetat activitatea"
    End If
    If (Eval("[Forms]![accordion_mainmenu].box1![Activ]=False And [Forms]![accordion_mainmenu].box1![InactivDin] Is Null")) Then
        Forms![accordion_mainmenu].Box1!InactivDin = Date
    End If
    If (Eval("[Forms]![accordion_mainmenu].box1![Activ]=True And [Forms]![accordion_mainmenu].box1![ActivDin] Is Null")) Then
        Beep
        MsgBox "Data la care a inceput activitatea in cadrul ISU Mures a fost setata la data curenta. Modificati daca este necesar!", vbOKOnly, "Data la care a inceput activitatea"
    End If
    If (Eval("[Forms]![accordion_mainmenu].box1![Activ]=True And [Forms]![accordion_mainmenu].box1![ActivDin] Is Null")) Then
        Forms![accordion_mainmenu].Box1!ActivDin = Date
    End If

End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:37
Joined
Sep 21, 2011
Messages
14,310
Thread is over 11 years old?

Please start your own post re your issue.
 

ABE86

New member
Local time
Today, 23:37
Joined
May 10, 2023
Messages
10
Thread is over 11 years old?

Please start your own post re your issue.
did so, 10x for the sugestion
/forums/threads/run-time-error-5-invalid-procedure-call-or-argument.329119/
 

Users who are viewing this thread

Top Bottom