473,762 Members | 7,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error : "statement invalid outside type block" need help here

143 New Member
Hello All..
I m having some problem here.. i m using VB6 and SQLServer 2000... i m getting this error " statement invalid outside type block"
i m sending u the code and the bold line is where i m getting the error
can anyone help me.. i dont knw whr i m doing mistake..
thankx in advance




Private Sub Toolbar1_Button Click(ByVal Button As MSComctlLib.But ton)

ID As Integer
On Error GoTo ChkErr

Const FIND_BUTTON = 2


Dim RsInd As New ADODB.Recordset
ID = Val(MSHFlexGrid 1.TextMatrix(MS HFlexGrid1.RowS el, 1))


If Button.Index = 3 Then ' ADD

ID = 0

Dim Rs As New ADODB.Recordset
If Rs.State = adStateOpen Then Rs.Close
Rs.Open ("SELECT * FROM casemaster"), Db, adOpenKeyset, adLockPessimist ic
If Rs("StopTran"). Value = 1 Then
MsgBox " Transactions Not Allowed "
Rs.Close


ElseIf Button.Index = 3 Then
Mode = "Add"
Call AddMode
Call ClearControl
End If

End


ElseIf Button.Index = 4 Then
Mode = "View"
frmCaseMaster.V isible = False
Call ClearControl
Call View


ElseIf Button.Index = 5 Then

If Rs.State = adStateOpen Then Rs.Close
Rs.Open

Mode = "Edit"
'Frameview.Visi ble = False
'cmdClearItem.V isible = True
Call Edit

End If

If Button.Index = FIND_BUTTON Then
frmFind.Show


ElseIf Button.Index = 8 Then
Unload Me

ElseIf Button.Index = 6 Then ' Save
Call save

frmCaseMaster.V isible = False
'SSTab1.Tab = 0

ElseIf Button.Index = 7 Then ' Cancel
If txtId.Text <> "" Then
Toolbar1.Button s.Item(3).Enabl ed = True
Toolbar1.Button s.Item(4).Enabl ed = True
MsgBox " Id'" & txtId.Text & " ' Is canceled"

Call Grid_Data
frmCaseMaster.V isible = True
Toolbar1.Button s.Item(7).Enabl ed = False ' Cancel

End If
End If
'End If
Exit Sub
ChkErr:
If Err.Number > 0 Then
MsgBox Err.Number & vbNewLine & Err.Description
Call ErrHand(Me.Capt ion, "Form_Initializ e")
'Resume Next
End If
End Sub
Dec 22 '08 #1
15 8683
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Declaration statements need "DIM",
Change the line to:

Dim ID As Integer

Regards
Veena
Dec 22 '08 #2
squrel
143 New Member
Oh.. sorry i forgot tht.. bt now i m getting this error..
"Item can not be found in the collection corresponding to the requested name or ordinal" and after pressing ok it says " path not found"
wht i shld do now??
thankx
Dec 22 '08 #3
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

What line are you getting Errors.?

Regards
Veena
Dec 22 '08 #4
squrel
143 New Member
no line is giving me error.. when i press on the add button or any other button tht error is coming...
Dec 22 '08 #5
squrel
143 New Member
i have 8 buttons.. and using toolbar for tht...(Sort,Fin d,Add,View,Edit ,Save,Cancel,Ex it)

when i m pressing on edit or view its telling me "the connection cannot be used to perform this operation. it is either closed or invalid in this context" and then after tht say " path not found" ..

i dont knw if i m using the toolbar in a write way.. wld u plz check the code which i send it up and tel me whr is wrong..
thank u very much
Dec 22 '08 #6
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

I Guess, "Db" is your Connection Object..
In form_Load event, You have to Make Connection to the database, before you start querying..
Check that Connection is made, and Database Path is selected appropriately..

REgards
Veena
Dec 22 '08 #7
squrel
143 New Member
this is my form load


Private Sub Form_Load()
On Error GoTo ChkErr
'Dim i As Integer

Dim Rs As New ADODB.Recordset
If Rs.State = adStateOpen Then Rs.Close
Rs.Open ("select * from casemaster"), Db, adOpenKeyset, adLockPessimist ic


Dim NewColumn As MSComctlLib.Col umnHeader
'cmdShowList.Vi sible = True
Toolbar1.Button s.Item(1).Enabl ed = True ' Sort
Toolbar1.Button s.Item(2).Enabl ed = True ' Find
Toolbar1.Button s.Item(3).Enabl ed = True ' Add
Toolbar1.Button s.Item(4).Enabl ed = True ' View
Toolbar1.Button s.Item(5).Enabl ed = True ' Edit
Toolbar1.Button s.Item(6).Enabl ed = True ' Save
Toolbar1.Button s.Item(7).Enabl ed = True ' Cancel
Toolbar1.Button s.Item(8).Enabl ed = True ' Exit


Call Grid_Data
Exit Sub
ChkErr:
If Err.Number > 0 Then
MsgBox Err.Number & vbNewLine & Err.Description
Call ErrHand("frmCas eMaster", "Form_Load" )
'Resume Next
End If

Grid_Data
End Sub
Dec 22 '08 #8
QVeen72
1,445 Recognized Expert Top Contributor
Where is the Code to Connect to the database..?
I Did ask, Is connection made?
Also, remove error-handlers, to check if you have and runtime errors, in form load..

Regards
Veena
Dec 22 '08 #9
squrel
143 New Member
i m so confuse using this toolbar... i dont knw if i m using it rit... now my add is working bt my save is not... do u have any sample of toolbar code tht i can check it... or can u help me in any other way.. i have to make this
thankx
Dec 22 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3013
by: Stephen Poley | last post by:
Could some kind soul explain the errors and warnings that the W3C CSS validator generates for page: http://www.atlis.nl/testsite/nl/ Results at: http://tinyurl.com/5pxqx The error "Invalid number : borderParse Error - " may be due to something I've done, but I'm blowed if I can see what. While the warning "property display doesn't exist for media" has me baffled.
9
1966
by: Wally | last post by:
I am trying to display images from an Access 2000 database and I get an error "Invalid Parameter Used" when I execute the code line "picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual Basic .Net application. I have researched MSDN for help and found the example article 321900 (see below) and set up a test and everything works fine when I use SQL Server 2000 but when I modify the code and use data from Access 2000 using an...
10
3361
by: jeff regoord | last post by:
A user inputs a float value. The scanf() function gets the value. However, I need to create an error handler with an if else statement saying invalid input if the input is not a number. Does anybody know how I could do this?
2
2878
by: crjunk | last post by:
I'm trying to write a piece of code that will programatically save a record automatically without me having to add a new ' Row.Item("ADD1") = txtAdd1.Text.Trim.ToUpper ' type command each time I add a new textbox. I've named all my textboxes in the following format txtAdd1 and I've named all my field in the SQL table the same way minus the txt at the beginning. This code scans the form for textboxes. If it finds a text box that is not...
6
2146
by: Patrick Dugan | last post by:
Hello, I'm trying to load different images (icons) into a PictureBox1.Image. The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't matter what icons are loaded. The first always shows up and any icons after that give me the error. Here is the offending code: The "DestinationPath" variable is the full path and filename of the icon
3
2587
by: Arnold | last post by:
I am having problem loading the image from the database. It gives this error: "Invalid parameter used." This is my source code: Private abyt() As Byte Private fo As New OpenFileDialog Private sf As New SaveFileDialog Dim strCn As String = "Data Source=DATABASE\BARCA;" & _ "Initial Catalog=MIS;Integrated Security=SSPI" Dim cn As SqlConnection = New SqlConnection(strCn) Dim fs As IO.FileStream
10
23083
by: asnowfall | last post by:
I get following compilation error C3149: 'System::String' : cannot use this type here without a top-level '^'. Could someone explain why I get this error? here is the code... ImageFileData.h ---------------------------
7
15005
by: The|Godfather | last post by:
Hi everybody, I read Scotte Meyer's "Effective C++" book twice and I know that he mentioned something specific about constructors and destructors that was related to the following error/warning: "error: invalid use of nonstatic data member " However, he did NOT mention this error in the book explicitly.It happens always in the constructor when you try to initialize some data members in the constructor and try to accsess other data...
1
3173
by: imranabdulaziz | last post by:
Dear All, I am using sql2005. i am writing stored procedure to save various master data . I recognize master by @type (input verible) and assign it to @mst veriable then based on @mst no I perform saving task . I created sp . now I am trying to execute then I am getting error “Invalid object name 'SizeMst'. “ I am running this query from its database. Stored perocedure is Alter procedure . @type int ,
0
9378
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9927
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.