Re: Runtime error 91: Object or with block variable not defined

Tech-Archive recommends: Fix windows errors by optimizing your registry



Alex aus V wrote:
- Visual Basic 6

Hallo

after I compiled my code in an exe-file. I get everytime the error message "Runtime error 91: Object or with block variable not defined" when I call this function

Private Sub txtAltColor_Click()
Dim cmDialog As Object
On Error Resume Next
Set cmDialog = CreateObject("MSComDlg.CommonDialog")
Err.Clear
cmDialog.Color = Me.BackColor
cmDialog.CancelError = True
cmDialog.flags = cdlCCRGBInit
cmDialog.ShowColor
If Err.Number = 0 Then
txtAltColor.BackColor = cmDialog.Color
txtAltColor.Text = cmDialog.Color
Else
If Err.Number <> 32755 Then 'Abbruch aktiviert
MsgBox "Error: " & Err.Number & " : " & Err.Description
End If
End If
End Sub

The txt-field is programed on a form witch is called over a mnu_xy_click()-function from the main form.
And there in a group of variabels for a tabstrip.
I get the same error message when I put the commonDialog-object diretly on the form.

I debug enviroment I don't get any error!!??

Where must I program the defionion of the object?

Regards


If you place

Private Const cdlCCRGBInit As Long = &H1

at the top of the form containing the above code, it should work.

Perhaps your error occurs elsewhere.

HTH
.



Relevant Pages

  • Runtime error 91: Object or with block variable not defined
    ... "Runtime error 91: Object or with block variable not defined" when I call ... Private Sub txtAltColor_Click ... Dim cmDialog As Object ... I get the same error message when I put the commonDialog-object diretly on ...
    (microsoft.public.vb.general.discussion)
  • RE: On Form Error: MsgBox
    ... just the form) I want it to prompt the first prompt in the code below then ... Can you help me modify the below code to prevent the above error message from ... Private Sub Form_Error(DataErr As Integer, Response As Integer) ...
    (microsoft.public.access.formscoding)
  • Re: Custom error message for Runtime error 3022
    ... The standard error message was triggered as soon as the ... Private Sub Form_Error ... Dim strMsg As String ... I don't think the Form Error triggers by runtime errors, ...
    (comp.databases.ms-access)
  • Re: Where to put my Error handling Code
    ... Private Sub Form_Error ... My error message popped up but then I think ... focus needs to be returned to that control so that the user can change it. ... Error event to display the Error number generated when the user violates your ...
    (microsoft.public.access.formscoding)
  • RE: Nested Datagrid spanning columns of Parent Datagrid
    ... The code you posted does not seem like the cause of the error message. ... Public Property CompanyPrimaryKey() As Integer ... Private Sub Page_Load ... "Phillip Williams" wrote: ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)