Results 1 to 8 of 8

Thread: Copy Data from Selected Record and place in new db and table on another form?

  1. #1

    Thread Starter
    Addicted Member Quizton's Avatar
    Join Date
    Dec 2005
    Location
    VB Forums
    Posts
    209

    Resolved Copy Data from Selected Record and place in new db and table on another form?


    Need a little bit of help with this one, I have searched for other alternatives as well as searching codebank surprised its not in there since i remember something along the lines of moving one table to the next wich is kinda what Im doing here so if I could get some good help on this one It would be very helpful
    I have a delete cmd and ATM it is set to delete the record all together. I recently added a new msg to the delete cmd "Employee has been moved to Past employee list"
    So here is the question I was wondering were would I place this new code and how would I go about doing it? I have tried multiple formulas and I am missing something still. Here Is my code that already displays the message but have not placed the move record command to it yet.
    vbCode___________________________________________________________
    Private Sub cmdDelete_Click()
    errormsg = MsgBox("Are You Sure You Want To Delete This Employee", vbYesNo, "Delete Record")
    If errormsg = vbYes Then
    errormsg = MsgBox("Employee Has Been Moved To Past Employee List", vbOKCancel, "Delete Record") <--Here is were I must move to new db table?
    If errormsg = vbOK Then
    rs.Delete <--Maybe a MoveTo PastRecord I cant quite get it right?
    Set rs = db.OpenRecordset("EMPDATA", dbOpenTable)
    list
    txtFirstName.Text = vbNullString
    txtFirstName.Enabled = True
    txtLastName.Text = vbNullString
    txtLastName.Enabled = True
    txtEmployed.Text = vbNullString
    txtEmployed.Enabled = True
    txtUnemployed.Text = vbNullString
    txtUnemployed.Enabled = True
    cmdSave.Enabled = True
    cmdCancel.Enabled = True
    cmdadd.Enabled = True
    Else
    Exit Sub
    End If
    End If
    End Sub
    ______________________________________________________________
    Well there is a sample of what I have at this current time I will gladly take any info on this matter and thanks in advance to all you pro's and good helpers out there
    thanks,
    Quiz
    Last edited by Quizton; Dec 30th, 2005 at 10:24 PM.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Delete Record then Moveing

    Are you looking for .MoveLast,.MoveNext,.MoveFirst and .MovePrevious commands?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Addicted Member Quizton's Avatar
    Join Date
    Dec 2005
    Location
    VB Forums
    Posts
    209

    Re: Delete Record then Moveing

    Something along the lines of When I delete the record it wont really delete but then it will move it to a different table(like a past records list)
    so it will delete from the normal table I have "EMPDATA" and then move to "PastEMPDATA"
    Thanks again Dee-u

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Delete Record then Moveing

    An example...

    VB Code:
    1. INSERT INTO Carrier ( CarrierCode, CarrierName, CarrierAdd1, CarrierAdd2, CarrierAdd3, CarrierAdd4, CarrierAdd5 )
    2. SELECT Carrier.CarrierCode, Carrier.CarrierName, Carrier.CarrierAdd1, Carrier.CarrierAdd2, Carrier.CarrierAdd3, Carrier.CarrierAdd4, Carrier.CarrierAdd5
    3. FROM Carrier
    4. WHERE (((Carrier.CarrierCode)=1));
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Delete Record then Moveing

    Isn't the logic is supposed to be something like this?

    VB Code:
    1. Private Sub cmdDelete_Click()
    2.     If MsgBox("Are You Sure You Want To Delete This Employee", vbYesNo, "Delete Record") = vbYes Then
    3.         'move the record before deleting
    4.         rs.Delete
    5.         Set rs = db.OpenRecordset("EMPDATA", dbOpenTable)
    6.         List
    7.         txtFirstName.Text = vbNullString
    8.         txtFirstName.Enabled = True
    9.         txtLastName.Text = vbNullString
    10.         txtLastName.Enabled = True
    11.         txtEmployed.Text = vbNullString
    12.         txtEmployed.Enabled = True
    13.         txtUnemployed.Text = vbNullString
    14.         txtUnemployed.Enabled = True
    15.         cmdSave.Enabled = True
    16.         cmdCancel.Enabled = True
    17.         cmdadd.Enabled = True
    18.     End If
    19. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6
    Fanatic Member
    Join Date
    Aug 2005
    Posts
    606

    Re: Delete Record then Moveing

    you want to
    copy the employees record from "Present employee DB" or probaly present employee table"
    add the employees record to a "past employeeDB" or probaly "past employee Table"
    delete employees record from "Present employee DB" or table

  7. #7
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Copy Selected Record Then Delete old wile new is in past records db

    You know how to add a record in a database right? It's just that, add it to the other table then delete it...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Copy Data from Selected Record and place in new db and table on another form?

    I'm very confused on this.
    VB Code:
    1. If errormsg = vbOK Then
    2. Set rs = db.OpenRecordset("PastEMPDATA", dbOpenTable)
    3. rs.update then
    4. Set rs = db.Openrecordset("EMPDATA",dbOpenTable)
    5. rs.Delete
    What type of objects are PASTEMPDATA and EMPDATA? Those should be SQL queries, but I'm guessing they are not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width