Edit button ?HELP PLEASE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Yamasassy
    New Member
    • Mar 2008
    • 15

    Edit button ?HELP PLEASE

    i have an edit button that is supposed enable the txt boxes to be able to write in it does this but when i click save i want the edited person to save


    [code=vb]
    Private Sub cmdEdit_Click(I ndex As Integer)

    txtFullname.Ena bled = True
    txtAddress.Enab led = True
    txtArea.Enabled = True
    txtPostcode.Ena bled = True
    txtContactno.En abled = True
    txtPos.Enabled = True
    txtSalary.Enabl ed = True

    End Sub

    Private Sub cmdExit_Click(I ndex As Integer)

    counter = EmployeeCollect ion.Count

    Dim forcounter As Integer

    Open "c:\temp\Storag e.txt" For Output As #1

    For forcounter = 1 To EmployeeCollect ion.Count

    Print #1, """" & EmployeeCollect ion.Item(forcou nter).Fullname & """,";
    Print #1, EmployeeCollect ion.Item(forcou nter).Address & ",";
    Print #1, EmployeeCollect ion.Item(forcou nter).Area & ",";
    Print #1, EmployeeCollect ion.Item(forcou nter).Postcode & ",";
    Print #1, EmployeeCollect ion.Item(forcou nter).Contactno & ",";
    Print #1, EmployeeCollect ion.Item(forcou nter).Pos & ",";
    Print #1, EmployeeCollect ion.Item(forcou nter).Salary

    Next
    Close #1
    End

    End Sub


    Private Sub cmdFirst_Click( Index As Integer)
    txtEmployeeno.T ext = 1

    txtFullname.Tex t = EmployeeCollect ion.Item(1).Ful lname
    txtAddress.Text = EmployeeCollect ion.Item(1).Add ress
    txtArea.Text = EmployeeCollect ion.Item(1).Are a
    txtPostcode.Tex t = EmployeeCollect ion.Item(1).Pos tcode
    txtContactno.Te xt = EmployeeCollect ion.Item(1).Con tactno
    txtPos.Text = EmployeeCollect ion.Item(1).Pos
    txtSalary.Text = EmployeeCollect ion.Item(1).Sal ary

    cmdP.Enabled = False
    cmdNext.Enabled = True


    If counter - 1 < 1 Then
    MsgBox ("First Record")

    End If


    End Sub

    Private Sub cmdsave_Click(I ndex As Integer)

    Set Employee = New clsEmployee

    Employee.Fullna me = txtFullname.Tex t
    Employee.Addres s = txtAddress.Text
    Employee.Area = txtArea.Text
    Employee.Postco de = txtPostcode.Tex t
    Employee.Contac tno = txtContactno.Te xt
    Employee.Pos = txtPos.Text
    Employee.Salary = txtSalary.Text

    txtFullname.Ena bled = False
    txtAddress.Enab led = False
    txtArea.Enabled = False
    txtPostcode.Ena bled = False
    txtContactno.En abled = False
    txtPos.Enabled = False
    txtSalary.Enabl ed = False

    EmployeeCollect ion.Add Employee
    txtEmployeeno.T ext = EmployeeCollect ion.Count
    Set Employee = Nothing

    End Sub
    [/code]


    Really greatfull for n e help
    yamasassy
    Last edited by debasisdas; Mar 13 '08, 05:40 AM. Reason: added code=vb tags
  • gobblegob
    New Member
    • Dec 2007
    • 133

    #2
    Originally posted by Yamasassy
    i have an edit button that is supposed enable the txt boxes to be able to write in it does this but when i click save i want the edited person to save


    [code]


    Private Sub cmdEdit_Click(I ndex As Integer)

    txtFullname.Ena bled = True
    txtAddress.Enab led = True
    txtArea.Enabled = True
    txtPostcode.Ena bled = True
    txtContactno.En abled = True
    txtPos.Enabled = True
    txtSalary.Enabl ed = True


    End Sub


    Really greatfull for n e help
    yamasassy

    So these are not being enabled?

    change this..
    Private Sub cmdEdit_Click(I ndex As Integer)

    to this..
    Private Sub cmdEdit_Click()

    GobbleGob.

    Comment

    • Yamasassy
      New Member
      • Mar 2008
      • 15

      #3
      sorry didnt make my self clear , when edited the detaikls save again not over write the persons details in the file

      Comment

      • gobblegob
        New Member
        • Dec 2007
        • 133

        #4
        Thats becuase your code only enables the objects for use, it doesnt tell your program do anything else.

        try this,

        [CODE=vb]Private Sub cmdEdit_Click(I ndex As Integer)
        Set Employee = New clsEmployee

        txtFullname.Ena bled = True
        txtAddress.Enab led = True
        txtArea.Enabled = True
        txtPostcode.Ena bled = True
        txtContactno.En abled = True
        txtPos.Enabled = True
        txtSalary.Enabl ed = True

        Employee.Fullna me = txtFullname.Tex t
        Employee.Addres s = txtAddress.Text
        Employee.Area = txtArea.Text
        Employee.Postco de = txtPostcode.Tex t
        Employee.Contac tno = txtContactno.Te xt
        Employee.Pos = txtPos.Text
        Employee.Salary = txtSalary.Text

        EmployeeCollect ion.Add Employee
        txtEmployeeno.T ext = EmployeeCollect ion.Count
        Set Employee = Nothing

        End Sub[/CODE]

        GobbleGob.
        Last edited by debasisdas; Mar 13 '08, 05:41 AM. Reason: added code=vb tags

        Comment

        Working...