Results 1 to 3 of 3

Thread: Help with data control

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2001
    Location
    Ohio
    Posts
    8

    Exclamation Help with data control

    Hi,

    I wrote this inventory program and am having a bit of a problem. I have it bound to a data control. When I make changes to a file and then cancel the change it writes the change to the data file anyway. Also, Can anyone tell me how to write code that will move to a record when the "part number" in entered? I don't want to have the data control visible but want to search records using the part number.

    Thanks!!!

    The Code:
    Private Sub cmdAddNew_Click()
    datDataControl.Recordset.AddNew
    'Clears the fields for new entry
    txtPartNumber = ""
    txtOrderQuantity = ""
    txtPrice = ""
    txtPartDescription = ""
    'Adds new record to the record set
    txtOrderQuantity.Locked = False
    txtPrice.Locked = False
    txtPartDescription.Locked = False
    End Sub

    Private Sub cmdCancel_Click()
    cmdCancel.Visible = False
    cmdUpdate.Visible = True
    cmdAddNew.Enabled = True
    cmdDelete.Enabled = True
    cmdDone.Enabled = False
    txtOrderQuantity.Locked = True
    txtPrice.Locked = True
    txtPartDescription.Locked = True
    datDataControl.Recordset.Requery
    End Sub

    Public Sub form_load()
    cmdDone.Enabled = False
    txtOrderQuantity.Locked = True
    txtPrice.Locked = True
    txtPartDescription.Locked = True
    End Sub
    Private Sub cmdDelete_Click()
    'Deletes a record
    If MsgBox("Are you sure you want to delete this item?", vbOKCancel + vbQuestion) = vbOK Then
    datDataControl.Recordset.Delete
    datDataControl.Recordset.MoveNext
    If datDataControl.Recordset.EOF Then
    datDataControl.Recordset.Requery
    datDataControl.Recordset.MoveLast
    End If
    End If
    End Sub

    Private Sub cmdDone_Click()
    datDataControl.Recordset.Edit
    MsgBox "Record has been updated successfully!", vbOKOnly + vbInformation
    cmdCancel.Visible = False
    cmdUpdate.Visible = True
    cmdAddNew.Enabled = True
    cmdDelete.Enabled = True
    cmdDone.Enabled = False
    txtOrderQuantity.Locked = True
    txtPrice.Locked = True
    txtPartDescription.Locked = True
    End Sub

    Private Sub cmdUpdate_Click()
    MsgBox "Change necessary data then click the Done button.", vbOKOnly + vbInformation
    cmdUpdate.Visible = False
    cmdCancel.Visible = True
    cmdAddNew.Enabled = False
    cmdDelete.Enabled = False
    cmdDone.Enabled = True
    txtOrderQuantity.Locked = False
    txtPrice.Locked = False
    txtPartDescription.Locked = False
    End Sub

    Private Sub mnuAdd_Click()
    datDataControl.Recordset.AddNew
    'Clears the fields for new entry
    txtPartNumber = ""
    txtOrderQuantity = ""
    txtPrice = ""
    txtPartDescription = ""
    'Adds new record to the record set
    txtOrderQuantity.Locked = False
    txtPrice.Locked = False
    txtPartDescription.Locked = False

    End Sub

    Private Sub mnuDelete_Click()
    'Deletes a record
    If MsgBox("Are you sure you want to delete this item?", vbOKCancel + vbQuestion) = vbOK Then
    datDataControl.Recordset.Delete
    datDataControl.Recordset.MoveNext
    If datDataControl.Recordset.EOF Then
    datDataControl.Recordset.Requery
    datDataControl.Recordset.MoveLast
    End If
    End If
    End Sub

    Private Sub mnuExit_Click()
    'Allows user to exit the program
    MsgBox "Are you sure you want to quit?", vbOKOnly + vbInformation
    End
    End Sub
    Raye...

  2. #2
    Jethro
    Guest
    Don't use early binding with data controls!!!!!!!!!!!!!!!!!!

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2001
    Location
    Ohio
    Posts
    8

    Unhappy

    I don't know whta ya mean by "early binding". Could you explain a bit??? Do you mean I should not bind it in the properties???
    Raye...

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