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
15 8684 QVeen72 1,445
Recognized Expert Top Contributor
Hi,
ToolBar Coding is OK, no problems with that..
In Save button, you are calling some procedure "Save",
What is the code there...?
Also Check the status of Recordset.. (If it is close, then Open..)
REgards
Veena
this is my code for save, view and edit
i m very sorry for trouble
and thank u very much for ur help
Public Function SaveCaseMaster( )
Db.Execute " Delete from casemaster where Id= '" & txtId.Text & "' "
Dim Rs As New ADODB.Recordset
If Rs.State = adStateOpen Then Rs.Close
Rs.Open ("CaseMaster "), Db, adOpenKeyset, adLockPessimist ic
With Rs
Rs.AddNew
.Fields("Id") = Val(txtId.Text)
.Fields("Descri ption") = Val(txtDescript ion.Text)
.Fields("casety pe") = Val(cmbCaseType .Text)
.Fields("caseId ") = Val(txtCaseId.T ext)
.Fields("compdi v") = Val(cmbCompDiv. Text)
.Fields("lodged by") = Val(cmblodgedby .Text)
.Fields("lodged date") = Format(Date, "DD-MMM-YYYY")
.Fields("sectio n") = Val(txtSec.Text )
.Fields("courtI d") = Val(txtCourtId. Text)
.Fields("fileno ") = Val(txtFileNo.T ext)
.Fields("party" ) = Val(cmbParty.Te xt)
.Fields("EntryD ate") = Format(Date, "DD-MMM-YYYY")
.Fields("closed ate") = Format(Date, "DD-MMM-YYYY")
.Update
End With
Rs.Close
End Function
Public Sub View()
Toolbar1.Button s.Item(1).Enabl ed = False ' Add
Toolbar1.Button s.Item(2).Enabl ed = False ' View
Toolbar1.Button s.Item(3).Enabl ed = False ' Sort
Toolbar1.Button s.Item(4).Enabl ed = True ' Edit
Toolbar1.Button s.Item(5).Enabl ed = False ' Save
Toolbar1.Button s.Item(6).Enabl ed = True ' Copy
Toolbar1.Button s.Item(7).Enabl ed = True ' Cancel
Call Grid_Data
frmCaseMaster.V isible = True
Call Disable
txtId.Text = Val(txtId.Text)
txtDescription. Text = Val(txtDescript ion.Text)
cmbCaseType.Tex t = Val(cmbcasetyp. Text)
txtCaseId.Text = Val(txtCaseId.T ext)
cmbCompDiv.Text = Val(cmbCompDiv. Text)
cmblodgedby.Tex t = Val(cmblodgedby .Text)
txtSec.Text = Val(txtSec.Text )
txtCourtId.Text = Val(txtCourtId. Text)
txtFileNo.Text = Val(txtFileNo.T ext)
cmbParty.Text = Val(cmbParty.Te xt)
txtCaseId.Text = Val(txtCaseId.T ext)
End Sub
Public Sub Edit()
Dim Rs1 As New ADODB.Recordset
If Rs1.State = adStateOpen Then Rs1.Close
Rs1.Open ("SELECT * from CaseMaster where Id = '" & ID & "'"), Db, adOpenKeyset, adLockPessimist ic
If Not Rs1.EOF And Not Rs1.BOF Then
Toolbar1.Button s.Item(1).Enabl ed = False ' Add
Toolbar1.Button s.Item(2).Enabl ed = False ' View
Toolbar1.Button s.Item(3).Enabl ed = False ' Sort
Toolbar1.Button s.Item(4).Enabl ed = False ' Edit
Toolbar1.Button s.Item(5).Enabl ed = True ' Save
Toolbar1.Button s.Item(6).Enabl ed = False ' Copy
Toolbar1.Button s.Item(7).Enabl ed = False ' Cancel
Toolbar1.Button s.Item(8).Enabl ed = False 'Find
Toolbar1.Button s.Item(8).Enabl ed = False 'Exit
' txtItemSrl.Text = Val(txtItemSrl. Text) + 1
Call Enable
Else
MsgBox " Cannot Edit"
frmCaseMaster.V isible = False
End If
End Sub
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
In your toolbar Click event change this line of code: ElseIf Button.Index = 6 Then
Call SaveCaseMaster
At the top of your Form's Code window, type this : Option Explicit
Most of the Compile errors can be caught..
REgards
Veena
those lines are already there.. i have done tht...
wld u plz just tel me tht is my code is rit for save, edit and view???.... thn i can work on it..
thank u very much :)
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
Your Code seems Quite right..
Note, you have Procedure names like "Save", "Edit", "Enable"...
These are Fixed Keywords.. Never use such words,,
Its a bit confusing, when you debug,
Cant you Change them to somewhat other names like "RecSave", "RecEdit"..
Regards
Veena
Hi Veena..
Ok.. i wil do tht and wil change the name... is there anything else tht u have noticed??
thank u
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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...
|
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?
|
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...
|
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
| |
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
|
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
---------------------------
|
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...
|
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 ,
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |