 |
| Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 14th, 2004, 01:06 PM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

May 14th, 2004, 01:09 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
hi there..
a little more info like what line of code throws the error would help...
HTH
Gonzalo
|
|

May 14th, 2004, 01:51 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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.
|
|

May 14th, 2004, 01:53 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

May 14th, 2004, 01:59 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
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
|
|

May 14th, 2004, 05:36 PM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am going to get back to you tonight
thank you for responding
|
|

May 15th, 2004, 08:08 PM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |