p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Beginning VB 6 (http://p2p.wrox.com/forumdisplay.php?f=75)
-   -   RUN TIME ERROR 91 (http://p2p.wrox.com/showthread.php?t=13000)

compcad May 14th, 2004 01:06 PM

RUN TIME ERROR 91
 
I had created a back end program for my clients program it works fine as a stand alone program. my client wants this back end to be only open from his program. I then created code to pass arguments to the back end. I have compiled the back end and ran the program from the front end. The back end would load MINIMIZED on the task bar and when I tried to MAXIMIZE the back end from the task bar I would get an error [Run time ERROR 91]. I need some help with this error here is some of the code i think the error is coming from.

CODE
Code:

Code:Private Sub Form_Activate()

Dim strValuesFromCommandLine() As String
Dim CmdLine As String
Dim RAFFLEID As String
Dim PASSWORD As String
Dim FirstTicketNo As String
Dim LastTicketNo As String
Dim number1 As String

 strValuesFromCommandLine() = Split(Command$, ", ")
 CmdLine = strValuesFromCommandLine(0)
 RAFFLEID = strValuesFromCommandLine(1)
 PASSWORD = strValuesFromCommandLine(2)
 FirstTicketNo = strValuesFromCommandLine(3)
 LastTicketNo = strValuesFromCommandLine(4)

If PASSWORD = "TheSecretPassword" Then
    If RAFFLEID > " " Then

        'Enter RaffielD into textbox and press OK.

        Data1.DatabaseName = DataPath
        Data1.Connect = "; PWD=TheSecretPassword"
        number1 = "select RaffieID, Prize1, NumberofTicketsAvailable, shortdescription, longdescription, raffleenddate, Ticketcost, " & _
        "Timeplace, CharityName from raffies Inner Join charity on Raffles.CharityIdd = charity.CharityId Where RaffielD like'" & RAFFLEID & "*'"
        Data1.RecordSource = number1
        Data1.Refresh
        Data1.Recordset.FindFirst "RaffleID = '" & RAFFLEID & "'"
    ElseIf Data1.Recordset.NoMatch Then
        Frame3.Visible = True
        Label4.Visible = True
        Label4.Caption = "No such record was found."
        End
        End If
ElseIf PASSWORD <> " TheSecretPassword" Then
    Label4.Visible = True
    Label28.Visible = False
    Label29.Visible = False
    Label4.Caption = "Enter the correct PASSWORD or see the administrator."
End If


DataPath = Mid(App.Path, 1, 29) & "rmdesktop\whdata.mdb"
DataPath1a = Right(DataPath, 11)

If Option2 = False Then
    txtValue.Enabled = False
    Text2.Enabled = False
    cmdPrint_Singles.Enabled = False
End If

If Option1 = False Then
    cmdPrint_All.Enabled = False
End If

End Sub

THANK YOU

If you need any more information I will get it to you

gbianchi May 14th, 2004 01:09 PM

hi there..
a little more info like what line of code throws the error would help...


HTH

Gonzalo

bmains May 14th, 2004 01:51 PM

Is maximized and minimized the window state property, where the window is minimized or maximized, or has this something to do with the database?

Thanks.

marcostraf May 14th, 2004 01:53 PM

Error 91 is object variable not set, the only object I can see in the code is Data1

BTW vb error handling is not great, but non using it is worse... :)

Marco

gbianchi May 14th, 2004 01:59 PM

probably this is wrong:

[code]
If RAFFLEID > " " Then
...
    ElseIf Data1.Recordset.NoMatch Then <----------- the data has not been set yet!!!!
        Frame3.Visible = True
        Label4.Visible = True
        Label4.Caption = "No such record was found."
        End
    End If

also

If PASSWORD = "TheSecretPassword" Then
...
ElseIf PASSWORD <> " TheSecretPassword" Then <--- why??? the if go to the second part if the first clause if not true..
    Label4.Visible = True
    Label28.Visible = False
    Label29.Visible = False
    Label4.Caption = "Enter the correct PASSWORD or see the administrator."
End If


[code]



HTH

Gonzalo

compcad May 14th, 2004 05:36 PM

I am going to get back to you tonight
thank you for responding

compcad May 15th, 2004 08:08 PM

I think I had found the area at which the program fails I had tried passing arguments from the code given to me by my client and tried opening the back end program with a false Password and it did ok and then I tried the RaffleId and it seemed to fail and so I figure that the RUN TIME ERROR 91 is comming from this portion of the code.

 
Code:

Data1.DatabaseName = DataPath
Code:

        Data1.Connect = "; PWD=TheSecretPassword"
        number1 = "select RaffieID, Prize1, NumberofTicketsAvailable, shortdescription, longdescription, raffleenddate, Ticketcost, " & _
        "Timeplace, CharityName from raffies Inner Join charity on Raffles.CharityIdd = charity.CharityId Where RaffielD like'" & RAFFLEID & "*'"
        Data1.RecordSource = number1
        Data1.Refresh
        Data1.Recordset.FindFirst "RaffleID = '" & RAFFLEID & "'"
    ElseIf Data1.Recordset.NoMatch Then
        Frame3.Visible = True
        Label4.Visible = True
        Label4.Caption = "No such record was found."
        End
        End If



before I Stuck the RaffleId code into Private Sub Form_Activate()I had it in a Command Button and it worked fine. At this time what should I do. What about put it into a Sub_Main() and then call it from there. Your advice is very helpful

THANK YOU



All times are GMT -4. The time now is 09:42 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.