Hello everyone,
I m using some button using toolbar such as Add,Save,View,.... my save button is not working.... it doesnt give me any error but does not save to my database.... or showing in my gird... Plz Help
here is my code for save button -
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
-
On Error GoTo ChkErr
-
If Button.Index = 1 Then
-
Mode = "Add"
-
Call AddMode
-
Call ClearControl
-
Toolbar1.Buttons.Item(1).Enabled = False ' Add
-
Toolbar1.Buttons.Item(2).Enabled = False ' View
-
Toolbar1.Buttons.Item(3).Enabled = False ' Sort
-
Toolbar1.Buttons.Item(4).Enabled = False ' Edit
-
Toolbar1.Buttons.Item(5).Enabled = True ' save
-
Toolbar1.Buttons.Item(9).Enabled = True 'Exit
-
-
End If
-
-
If Button.Index = 4 Then
-
'If Val(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.RowSel, 8)) = "0" Then
-
Mode = "Edit"
-
Toolbar1.Buttons.Item(5).Enabled = True ' save buton
-
Call Enable
-
Else
-
MsgBox " Cannot Edit "
-
End If
-
-
If Button.Index = 5 Then
-
-
Call SaveMode
-
Call ClearControl
-
Call Desable
-
MsgBox " Record Saved For Id '" & txtId.Text & "'"
-
Toolbar1.Buttons.Item(5).Enabled = False
-
Toolbar1.Buttons.Item(1).Enabled = True ' Add
-
-
Call Address
-
End If
-
-
'End If
-
-
If Button.Index = 2 Then ' View
-
'Toolbar1.Buttons.Item(7).Enabled = False ' Final
-
Toolbar1.Buttons.Item(1).Enabled = False ' Add
-
Toolbar1.Buttons.Item(4).Enabled = True ' Edit
-
-
End If
-
-
-
-
If Button.Index = 7 Then ' Cancel
-
Db.Execute "Update Address"
-
Call Address
-
-
End If
-
-
-
If Button.Index = 9 Then ' Exit
-
Unload Me
-
End If
-
-
Exit Sub
-
ChkErr:
-
If Err.Number > 0 Then
-
MsgBox Err.Number & vbNewLine & Err.Description
-
Call ErrHand(Me.Caption, "cmdSave_Click")
-
-
End If
-
End Sub
-
-
-
Public Function SaveMode()
-
'On Public Function SaveMode()
-
If Mode = "Add" Then
-
' To Get ReqNo from Mslastdoc
-
Dim Rs As New ADODB.Recordset
-
If Rs.State = adStateOpen Then Rs.Close
-
Rs.Open ("SELECT * FROM MsLastDoc where YY ='" & FinancialYear & "'"), Db, adOpenKeyset, adLockPessimistic
-
txtId.Text = Rs("LastDocNo").Value + 1
-
Rs.Close
-
' End
-
-
' Save LastDoc
-
Dim LastDoc As New ADODB.Recordset
-
Dim DocNo As Integer
-
DocNo = Val(txtId.Text)
-
If LastDoc.State = adStateOpen Then LastDoc.Close
-
LastDoc.Open ("Select * From MsLastDoc where YY ='" & FinancialYear & "' "), Db, adOpenKeyset, adLockPessimistic
-
Db.Execute "Update MsLastDoc set LastDocNo ='" & DocNo & "' where YY ='" & FinancialYear & "' "
-
' End Save
-
End If
-
-
Call SaveAddress
-
Call ClearControl
-
-
End Function
-
Public Function SaveAddress()
-
Db.Execute " Delete from Adress where Id = '" & txtId.Text & "' "
-
-
Dim RsAddress As New ADODB.Recordset
-
'If RsReqHdr.State = adStateOpen Then RsReqHdr.Close
-
RsAddress.Open ("Address"), Db, adOpenKeyset, adLockPessimistic
-
With RsAddress
-
RsAddress.AddNew
-
.Fields("Id") = Val(txtId.Text)
-
.Fields("Addressof") = Val(cmbadrof.Text)
-
.Fields("Address") = Val(txtAddress.Text)
-
.Fields("city") = Val(txtCity.Text)
-
.Fields("Pin") = Val(txtPin.Text)
-
.Fields("entrydt") = Format(DTPentrydt, "DD-MMM-YYYY")
-
.Fields("closedt") = Format(DTPClosedt, "DD-MMM-YYYY")
-
-
.Update
-
End With
-
RsAddress.Close
-
End Function
-
14 3656
Greetings, squrel!
I am not sure what the problem is, are you having problems with just your save mechanism? Did you know you can run the code in debug mode to follow what is happening. Please write if you need to know how to do that.
Do stay tuned for a better answer on this one, like I said I am not certain how this could go.
In a bit!
Dököll
plz tel me how to run it in a dubug mode... and non of my button is working... dont knw why? thank u
Hi,
First Remove the error Handling and Run the Code.
Keep a BreakPoint on First Line of the Code.
and Check the Run-Sequence..
Regards
Veena
Hi... i have changed the code to this but still i have error in this line :
'txtAddressId.Text = GetNextCode("Address", "AdrID")
why my getnextcode is not working? it gives me the error of Sub or function not defined? i dont get wht is the problem.... plz help... thankx
Option Explicit
Private Sub Form_Initialize()
On Error GoTo ChkErr
Db.Close
Db.ConnectionString = pStrConnectionString
Db.ConnectionTimeout = 0
Db.Open
Db.CursorLocation = adUseClient
DoEvents
Exit Sub
ChkErr:
If Err.Number > 0 Then
MsgBox Err.Number & vbNewLine & Err.Description
Call ErrHand(Me.Caption, "Form_Initialize")
'Resume Next
End If
End Sub
Private Sub Form_Load()
On Error GoTo ChkErr
FormUpdateSQL1.ConnectionString = pStrConnectionString
FormUpdateSQL1.TableName = "Address"
FormUpdateSQL1.FieldList = "AdrId;AdrOf;Address;City;Pin;Entrydt;Closedt;Ind; "
FormUpdateSQL1.ControlList = "txtId;cmbadrof;txtAddress;txtCity;txtPin;DTPentry dt;DTPclosedt;ChkInd;"
FormUpdateSQL1.ViewFields = "AdrId;AdrOf;Address;City;Pin;Entrydt;Closedt;Ind; "
FormUpdateSQL1.FormatString = "AdrId;AdrOf;Address;City;Pin;Entrydt;Closedt;Ind; "
FormUpdateSQL1.DoVisible 4, False
FormUpdateSQL1.DoVisible 6, False
FormUpdateSQL1.DoVisible 8, False
FormUpdateSQL1.AllowEdit = True
FormUpdateSQL1.Refresh
cmbadrof.Enabled = False
Call Grid_Data
Exit Sub
ChkErr:
If Err.Number > 0 Then
MsgBox Err.Number & vbNewLine & Err.Description
Call ErrHand("Address", "Form_Load")
'Resume Next
End If
Grid_Data
End Sub
Public Sub Grid_Data()
On Error GoTo ChkErr
Adodc1.ConnectionString = pStrConnectionString
Adodc1.RecordSource = "Select AdrID as ID,Adrof,Address,City,Pin,entrydt as EntryDate,closedt as CloseDate from Address"
Adodc1.Refresh
MSHFlexGrid1.ColWidth(1) = 800
MSHFlexGrid1.ColWidth(2) = 1000
MSHFlexGrid1.ColWidth(3) = 2000
MSHFlexGrid1.ColWidth(4) = 1000
MSHFlexGrid1.ColWidth(5) = 800
MSHFlexGrid1.ColWidth(6) = 1000
MSHFlexGrid1.ColWidth(7) = 2000
MSHFlexGrid1.Refresh
Exit Sub
ChkErr:
If Err.Number > 0 Then
MsgBox Err.Number & vbNewLine & Err.Description
Call ErrHand("Address", "Grid_Data")
'Resume Next
End If
End Sub
Private Sub FormUpdateSQL1_AddClick()
cmbadrof.Enabled = True
'txtAddressId.Text = GetNextCode("Address", "AdrID")
cmbadrof.Enabled = True
ChkInd.Value = 1
End Sub
Private Sub FormUpdateSQL1_AfterControlsEnabled()
cmbadrof.Enabled = True
End Sub
Private Sub FormUpdateSQL1_AfterUpdate()
cmbadrof.Enabled = False
Call Grid_Data
End Sub
Private Sub FormUpdateSQL1_BeforeValidate()
If cmbadrof.Text = "" Then
MsgBox " Enter the selected address"
cmbadrof.SetFocus
Exit Sub
FormUpdateSQL1.CancelEvent = True
End If
End Sub
Private Sub MSHFlexGrid1_DblClick()
FormUpdateSQL1.ViewRecord True, Val(MSHFlexGrid1.Text)
End Sub
Is anyone can help me in this matter??
txtAddressId.Text = GetNextCode("Address", "AdrID")
This looks like you are calling a Function...
and you may not have that Function in your code, and the Error is the same...
Regards
Veena
Hi
In this code how can i get the next Id?? I mean if i have 7 record saved in this, when i press the add button i want the no 8 appears in my txtId... Can anyone help me plz... thankx a lot
Hi Guys..
I need some help here if anyone can.. thankx
Hi,
Write this Function :
{AIRCODE} -
Private Function MyNextID() As Long
-
Dim RSI As New ADODB.RecordSet
-
MyNextID = 0
-
RSI.Open "Select Max(ID) From MyTable",Conn
-
If Not RSI.EOF Then
-
RSI.MoveFirst
-
MyNextID = Val(RSI(0) & "")
-
End If
-
MyNextID = MyNextID + 1
-
RSI.Close
-
Set RSI = Nothing
-
End Function
-
Call the above Function, In cmdADD_Click
Regards
Veena
Hi Veena..
That Code is not working in my project... my add function is this
Private Sub FormUpdateSQL1_AddClick()
cmbadrfor.Enabled = True
'txtId.Text = GetNextCode("Address", "AdrID")
cmbadrfor.Enabled = True
txtId.Enabled = False
ChkInd.Value = 1
End Sub
tht part of the code is not working in my function... wht else i can do..
thanks a lot
Hi,
you are using VB6 or VBA....?
My code is for VB6
Regards
Veena
I m using VB6 with SQLserver 2000
Hi,
Did you add the Function what I said in My previous post..?
Yes i added tht function the same way u told me but it is not working and still getting error
Sign in to post your reply or Sign up for a free account.
Similar topics
by: PK |
last post by:
Hello,
I am looking for help on the following. I'm trying to create a custom
browser toolbar button that will do a few things. One that I'm trying
to do at the moment is just simply return the...
|
by: jbbs |
last post by:
I have a question regarding on the button and label.
i don't know why when the mouse cursor points on the button, i see the button is flirking. is there anyway to make it not behave like that?...
|
by: Lauren Quantrell |
last post by:
I use the following code to create text edit fields and command buttons
in my toolbars:
Function CreateToolbarObject(myObjectType as integer)
Dim newObject
Select Case myObjectType
Case 1...
|
by: IntraRELY |
last post by:
I am using the following command to launch and .NET VB Executable, which is
a simple Windows Form (printCheckClient.exe). I am using a HyperLink Control
and works perfect....
|
by: jake |
last post by:
How do you get or save a file from/to a client (button on web page) once
they are authenticated? The client could be Mac, Linux or Windows. Can I do
it all with IIS and ASP.NET?
|
by: Mark Goldin |
last post by:
I have a toolbar on my form.
How do I know what button was clicked?
|
by: reidarT |
last post by:
I have entered a BindingNavigator toolbar in a bound form and can manage to
browse records and I am able to enter data in a new record.
I am ot able to save the data and therefore I have entered...
|
by: Angus |
last post by:
I have a web page with a toolbar containing a Save button. The Save
button can change contextually to be a Search button in some cases.
Hence the button name searchsavechanges.
The snippet of...
|
by: manjesh |
last post by:
hi ,
kindly help to create a toolbar with that new , save , edit, cancel button ,
if i open each form to operate this buttons ,instead of placing in each form .
regards
manjesh
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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...
| |