I am a newbie in visual basic, when i tried to run this code,the above error pops up.I have declared an user defined function named initiative but for no reason the error pops up.
Private Sub initiate()
For i = 0 To 2
COURSE(i).Value = False
SEM(i).Value = False
If i <> 2 Then
ODDEVEN(i).Value = False
End If
Any help is appreciated.
Related
I am coming across error 438 when running code to open 2 tabbed forms from 1 reference ID from another form; It opens the forms correct with the looks of the Data but shows the error -
Error Number: 438
Object doesn't support this property or method
I believe the error to be as to .filter isn't working, because a filter is already applied - however the results look correct as current the 2 sub tabbed forms open on the correct record but the error still shows every time
I would like the below code to run without the error can anyone make any suggestions - (not just error handling to ignore error)
Public Function Open()
On Error GoTo Err_LogError
Dim stLinkCriteria As String
Dim stLinkCriteria1 As String
stLinkCriteria = "[CaseID]=" & Me![ID]
stLinkCriteria1 = "[CaseID]=" & Me![ID]
Forms!frmHome!frmTabs.Form.Visible = True
Forms!frmHome!frmTabs.Form!frmLiveTasks.SetFocus
Forms!frmHome!frmTabs.Form!frmLiveTasks.Form.Filter = stLinkCriteria
Forms!frmHome!frmTabs.Form!frmLiveTasks.Form.FilterOn = True
Forms!frmHome!frmTabs.Form.Visible = True
Forms!frmHome!frmTabs.Form!frmLiveInfo.SetFocus
Forms!frmHome!frmTabs.Form!frmLiveInfo.Form.Filter = stLinkCriteria1
Forms!frmHome!frmTabs.Form!frmLiveInfo.Form.FilterOn = True
Exit Function
Err_LogError:
Call ErrorHandle
End Function
It transpired that the code worked - but the error was linked to another section of VBA
I have a filed called application. I have written code in vba to make the other field "application_txt" field visible and invisible if a particular value from application field is selected. But for this particulat field application when I write the below code in vba it throws the error. I dont understand why. It works fine for the other fields. Below is the code:
Can anyone please help me with this problem. Is it allowed to give application as field name in MS Access.
Many thanks,
Kiran Chapidi
This is not working:
Private Sub application_Click()
If application.Value = "5= others" Then
Me.application_txt.Visible = True
Else
Me.application_txt.Visible = False
End If
End Sub
This is working fine:
Private Sub Design_Click()
If Design.Value = "3= others" Then
Me.design_txt.Visible = True
Else
Me.design_txt.Visible = False
End If
End Sub
I'm having a peculiar issue with a VBA assignment for school. The issue I'm having is VBA is giving me a compile error when Excel tries running the code at start up on a specific Workbook. It keeps telling me that the code cannot be run outside a procedure, but I don't know why it's telling me that when it needs to run at the start of the document. Here's my almost final code that's throwing the error...
Option Explicit
Worksheets("StartPage").Activate
Worksheets("Payroll").Protected
cmdDisplay.Enabled = False
cmdEmpData.Enabled = False
cmdEmployees.Enabled = True
cmdReset.Enabled = True
Public intNumEmp As Integer
That code runs BEFORE the first subroutine is run, which, aside from the variable, is throwing the error. Should I put an access modifier before them to fix the issue, or is there something else I'm missing?
#RonRosenfeld is correct, here is what the code would look like inside of the ThisWorkbook module:
Option Explicit
Public intNumEmp As Integer
Private Sub Workbook_Open()
Worksheets("StartPage").Activate
Worksheets("Payroll").Protected
cmdDisplay.Enabled = False
cmdEmpData.Enabled = False
cmdEmployees.Enabled = True
cmdReset.Enabled = True
End Sub
I am trying to close my Visual Basic Editor window. I couldn't find any perfect code for this. These are the previous suggested codes i have tried,
1) Application.VBE.MainWindow.Close
2) Application.VBE.ActiveWindow.Close
3) Application.VBE.ActiveCodePane.Window.Close
If I run any of these codes, i am getting the following Run time error(6068)
"Programmatic Access to Visual Basic Project is not trusted".
Please tell me if there is any solution for this problem.
Application.ShowVisualBasicEditor = False
Application.VBE.MainWindow.Visible = False
tested with:
Sub hideVBE()
MsgBox "foo"
Application.VBE.MainWindow.Visible = True
MsgBox "bar"
Application.VBE.MainWindow.Visible = False
End Sub
I'm maintaining a vb6 project(ActiveX DLL). When debugging, the app run into the following function:
Public Function HasValue(ByVal vValue) As Boolean
On Error GoTo Err
If IsMissing(vValue) Then
HasValue = False
ElseIf IsNull(vValue) Or Len(vValue) = 0 Then
HasValue = False
ElseIf isEmpty(vValue) Then
HasValue = False
Else
HasValue = True
End If
Exit Function
Err:
If IsArray(vValue) Or IsObject(vValue) Then
HasValue = True
Else
HasValue = False
End If
End Function
and it stops at the line
ElseIf IsNull(vValue) Or Len(vValue) = 0 Then
vValue is a custom object, contains some properties(obviously, not null).
Although I didn't put any break point there, the app stopped there and alerted error dialog saying that "Run-time error '438': Object doesn't support this property or method".
We had error handling code but the app didn't run to error handling code. It just stopped at the line causing the error and I had to stop the application.
Do you have any idea about that?
Thank you very much.
As far as getting the popup running in the debugger, it is probably related to your "Error Trapping" settings in the IDE. Go To Tools->Options->General and see what selected under "Error Trapping". At first glance it seems odd that your error handler is testing the vValue in the event of an error. It makes more sense to me based on my limited understanding of this method to move both the IsArray and IsObject conditions up into the main testing logic. Just my 2 cents :)
As far as i know vb6 does not support boolean short evaluation in
ElseIf IsNull(vValue) Or Len(vValue) = 0 Then
so Len(vValue) = 0 is executed even if IsNull(vValue) is true.
changing your code to
...
ElseIf IsNull(vValue) Then
HasValue = False
ElseIf Len(vValue) = 0 Then
HasValue = False
ElseIf ...
might solve the problem