Run Time Error'91'
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Run Time Error'91'

  1. #1
    Join Date
    Sep 2010
    Posts
    38

    Run Time Error'91'

    Private Sub cmdAcchu_Click()
    Set obj = New PrinterControl
    obj.ChngOrientationLandscape

    rec.Open "select * from reser where reno = '" & Combo1.Text & "'", con, 1, 3

    If rec.RecordCount = 0 Then
    MsgBox "No record found on query.", vbCritical, "Medrar"

    Else
    Set Reservation.DataSource = rec
    Unload Me
    Reservation.Show
    End If

    Set rec = Nothing

    End Sub

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,830

    Re: Run Time Error'91'

    Well you did not tell us which line the error was pointing to and you did not show us any public vars if they exist and apparently you could not bother to post properly with code tags or even give us the description of the error.

    obj is not defined nor is rec or con. I guess you expect us to guess where these are defined and where the error occurs.

    Provide more info and use code tags please.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Aug 2009
    Posts
    100

    Re: Run Time Error'91'

    I'm going to guess that the text of combo1 is null, which will throw an error when you attempt to call it as you are. But as DM said, you need to provide much more information in order for us to help you.

  4. #4
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,830

    Re: Run Time Error'91'

    Actually in this instance a null value in combo1 should not cause an error there as it would be treated like an empty string and likely not return any matches. Error 91 indicates that a reference is made to an object that has not been initialized. Given the code in the OP it could the the rec object, the con object, or one of the other objects.

    What is printercontrol? Are rec and con set as public or form level variables elsewhere? Is the con object initialized and opened elsewhere? I assume Reservation is a form in the project. From the code provided and total lack of any info other than the error number it is impossible to say what the error is.
    Last edited by DataMiser; June 29th, 2011 at 03:54 PM.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: Run Time Error'91'

    i.e.: trying to PRINT a record?

    Need to PRINT THE FORM, IF THERE IS A RECORD
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center