|
-
Jan 13th, 2017, 11:45 AM
#1
Thread Starter
Fanatic Member
error 5 invalid procedure call or argument set form hide event or change visible
Hi
When I try to call event hide in form , return me error 5 invalid procedure call or argument
The error only show in run time execution, not show in design
Inside form2 there is a button
Code:
Private Sub cmdCancel_Click()
'--- other commands
Me.Hide '-- here in return error in run time execution
'-- others commands
'-- try too me.visible = false , but show same error
end sub
The compiler VB is in VM (Virtualbox) SO XP and I run in win10
I search in forum , and not see something equal
Last edited by mutley; Jan 13th, 2017 at 11:48 AM.
Reason: put when visible = false
-
Jan 13th, 2017, 12:44 PM
#2
Re: error 5 invalid procedure call or argument set form hide event or change visible
I would say you have some other code somewhere that is causing your issue.
What you have shown there should work
-
Jan 13th, 2017, 02:11 PM
#3
Re: error 5 invalid procedure call or argument set form hide event or change visible
I'd have to agree that what you've shown should work.
However, one caveat/warning. Once you issue that Me.Hide command, you've released your Form2 from being modal. In other words, once "Me.Hide" is executed, your original code (which halted on the "Form2.Show 1") will resume execution. Maybe it's something about the code after the "Form2.Show 1" that's causing the problem.
Good Luck,
Elroy
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 15th, 2017, 12:47 AM
#4
Thread Starter
Fanatic Member
Re: error 5 invalid procedure call or argument set form hide event or change visible
 Originally Posted by Elroy
I'd have to agree that what you've shown should work.
However, one caveat/warning. Once you issue that Me.Hide command, you've released your Form2 from being modal. In other words, once "Me.Hide" is executed, your original code (which halted on the "Form2.Show 1") will resume execution. Maybe it's something about the code after the "Form2.Show 1" that's causing the problem.
Good Luck,
Elroy
Thank you
The problem is that for others called in same form/same application work fine, the form2 is in a library and Is instantiated by array
Code:
Dim maarrayform() As New form2
'....code
'... code
If maarrayform(pintLOVId)!cmdActivate.Tag Then
' Show the form as a modal dialog
maarrayform(pintLOVId).Show MODAL
' If the user has chosen OK then return True, else return False
If maarrayform(pintLOVId)!zsAction = "OK" Then
isactive = True
Else
isactive = False
End If
Else
isactive = False
End If
-
Jan 15th, 2017, 08:56 AM
#5
Re: error 5 invalid procedure call or argument set form hide event or change visible
The problem is more likely on the form you are trying to hide
-
Jan 16th, 2017, 05:17 AM
#6
Thread Starter
Fanatic Member
Re: error 5 invalid procedure call or argument set form hide event or change visible
 Originally Posted by DataMiser
The problem is more likely on the form you are trying to hide
Hi Thank you, but strange is that same application same form It workfine , and why only time execution show me error, when in design work fine too
see videos in time execution
https://app.box.com/s/gdmr6331wfdl313lh6nni2xw1yyq09z5
-
Jan 16th, 2017, 12:40 PM
#7
Thread Starter
Fanatic Member
Re: error 5 invalid procedure call or argument set form hide event or change visible
Hi
Will be if I to install service pack 6, can to help ?
-
Jan 16th, 2017, 05:06 PM
#8
Re: error 5 invalid procedure call or argument set form hide event or change visible
 Originally Posted by mutley
Hi
Will be if I to install service pack 6, can to help ?
I don't think.
Your error is that you can't hide a modal form. It's totally wrong.
-
Jan 16th, 2017, 06:52 PM
#9
Thread Starter
Fanatic Member
Re: error 5 invalid procedure call or argument set form hide event or change visible
 Originally Posted by gibra
I don't think.
Your error is that you can't hide a modal form. It's totally wrong.
Do Can not hide a modal form ? Why ?
-
Jan 16th, 2017, 07:48 PM
#10
Re: error 5 invalid procedure call or argument set form hide event or change visible
Yes you can hide a form that has been shown modal.
Not sure why anyone would say you can't.
Your problem is very likely not the hide statement but some other code that you have not shown.
SP6 should be installed of course but I do not think that would be the problem, I've been using VB6 before any service packs and with every service pack that came out and never saw any problem with what you are seeing.
-
Jan 16th, 2017, 08:43 PM
#11
Hyperactive Member
Re: error 5 invalid procedure call or argument set form hide event or change visible
Your question, mutley, I believe was answered by DataMiser in your other thread
-
Jan 17th, 2017, 05:02 AM
#12
Re: error 5 invalid procedure call or argument set form hide event or change visible
 Originally Posted by mutley
Do Can not hide a modal form ? Why ?
A modal form is normally used for user input standby.
What sense does it hide?
-
Jan 17th, 2017, 05:18 AM
#13
Thread Starter
Fanatic Member
Re: error 5 invalid procedure call or argument set form hide event or change visible
Hi
Sorry , but my english is bad, but I tried to explain the problem with pictures
First main form

after form work fine
  
now form with error

called the function in lostfocus control
Code:
Private Sub txtNCMCLASSE_LostFocus()
Dim discard As Integer
If Me.ORIGEM <> 0 Then
If Not gNoLostFocusValidation Then
If gNCMCLASSE = "NCM" Then
discard = PESQ_FKV_NCM_CODIGO()
Else
discard = PESQ_FKV_CMERC()
End If
End If
End If
Exit Sub
End Sub
calling PESQ_FKV_CMERC, Inside It call PESQ_FKL_CMERC
Code:
Private Function PESQ_FKV_CMERC() As Integer
On Error GoTo PESQ_FKV_CMERC_Error
PESQ_FKV_CMERC = False
Dim bFoundValue As Integer
Dim dysFKVal As Object
Dim strSQL As String, strFKWhere As String
' If the data entry control is empty, clear the dependant lookups
PESQ_FKV_CMERC = False
bFoundValue = False
bFoundValue = False
' Build up the SQL statement,
strSQL = gSQL_KEYWD_SELECT & "CCM.CMERC_CODIGO CMERC_CODIGO"
strSQL = strSQL & ",CCM.CMERC_NOME NOME"
strSQL = strSQL & gSQL_KEYWD_FROM & "COR_CLASSE_MERCADORIA CCM"
strFKWhere = "upper(CCM.CMERC_CODIGO) = :C1"
' Set up the bind parameter values
gDatabase.Parameters.Remove "C1"
Call ldSetParamVal("C1", "C", UCase(txtNCMCLASSE))
' Create the Dynaset to look for row matching value entered
Set dysFKVal = gDatabase.dbcreatedynaset(strSQL & gSQL_KEYWD_WHERE & strFKWhere, 2&)
' If there are no rows in the dynaset, then clear the controls,
' issue a message, (and return False).
If Not dysFKVal.EOF Then
bFoundValue = True
Else
' Refresh the Dynaset using the LIKE operator instead of equals
strFKWhere = "upper(CCM.CMERC_CODIGO) LIKE :C1 || '%'"
dysFKVal.SQL = strSQL & gSQL_KEYWD_WHERE & strFKWhere
dysFKVal.DBRefresh
' Have we found at least one row
If Not dysFKVal.EOF Then
' Is there exactly one row matching the LIKE operator
dysFKVal.DbMoveNext
If dysFKVal.EOF Then
' Exactly one row found one row found
dysFKVal.DbMovePrevious
bFoundValue = True
Else
' More than one row found - display the LOV dialog
If PESQ_FKL_CMERC(strFKWhere, CStr(UCase(txtNCMCLASSE))) Then
' User picked a row from the dialog - refresh dynaset using the value
' that the user selected
gDatabase.Parameters.Remove "C1"
Call ldSetParamVal("C1", "C", UCase(txtNCMCLASSE))
strFKWhere = "upper(CCM.CMERC_CODIGO) = :C1"
dysFKVal.SQL = strSQL & gSQL_KEYWD_WHERE & strFKWhere
dysFKVal.DBRefresh
If Not dysFKVal.EOF Then
bFoundValue = True
End If
End If
End If
End If ' LIKE search found at least one row
' End If
If bFoundValue Then
' If we found a row, copy the values into the lookup controls
txtNCMCLASSE = dysFKVal("CMERC_CODIGO")
PESQ_FKV_CMERC = True
Else
lgMsg "Inválido valor para Classe de Mercadoria", gMG_SEV_WARN
End If
End If
Exit Function
PESQ_FKV_CMERC_Error:
Call lgMsgVBError("frmnecmQD", "PESQ_FKV_CMERC", Err, Error)
End Function
Code PESQ_FKL_CMERC, Inside It call function ldLOVActivate Is module in LIBRAY that invoke the form LOV too in libray,
in return the button cancel in the form occur error
Code:
Private Function PESQ_FKL_CMERC(pstrWhere As String, pstrBindVals As String) As Integer
Dim intLOVId As Integer ' Handle to the LOV created/found
Dim strFrom As String ' Tables involved in LOV
Dim strDesWhere As String ' Any fixed Where clause
Dim strRunWhere As String ' Run time Where clause based on input from user
' Set up Error Handling, and set default function return
On Error GoTo PESQ_FKL_CMERC_Error
PESQ_FKL_CMERC = False
' Turn off firing the LostFocus event to prevent validation of current value
gNoLostFocusValidation = True
strRunWhere = pstrWhere
If strRunWhere = "" Then
' Get value from user to qualify SELECT statement
If Not lgMsgAskQueryValue("CCM.CMERC_CODIGO", "Código da CLASSE", 6, True, strRunWhere) Then
GoTo PESQ_FKL_CMERC_Exit
End If
End If
strFrom = "COR_CLASSE_MERCADORIA CCM"
'strDesWhere = "CCM.CMERC_CODIGO IN ( SELECT T.CMERC_CODIGO FROM EXF_CLASSIFICACAO_NCM T)"
If ldLOVDefine("FK/NECM/CMERC_CODIGO", "Classe de Mercadoria", 0, strFrom, strDesWhere, intLOVId) Then
Call ldLOVDefineField(intLOVId, 1, "CCM.CMERC_CODIGO", 6, "Código da CLASSE")
Call ldLOVDefineField(intLOVId, 2, "RPAD(CCM.CMERC_NOME, 200)", 200, "Nome")
End If
' Invoke the LOV. True returned if user picks a row from the list
If ldLOVActivate(intLOVId, strRunWhere, pstrBindVals) Then
' Populate the control with the obtained value.
txtNCMCLASSE = ldLOVRetVal(intLOVId, 1)
PESQ_FKL_CMERC = True
End If
PESQ_FKL_CMERC_Exit:
gNoLostFocusValidation = False
Exit Function
PESQ_FKL_CMERC_Error:
Call lgMsgVBError("frmnecmQD", "PESQ_FKL_CMERC", Err, Error)
GoTo PESQ_FKL_CMERC_Exit
End Function
Some objects are in
https://app.box.com/s/myx1d53cx9stdy0r728i23fz94corg1p
 
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|