p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access (http://p2p.wrox.com/forumdisplay.php?f=18)
-   -   How to delete current record in bounded form? (http://p2p.wrox.com/showthread.php?t=30607)

method June 19th, 2005 04:37 PM

How to delete current record in bounded form?
Hi guys. I made bounded maintenance form customer table in my access db.
But when I try to delete a record by clicking on the delete button I get
the following error. I be happy if some one help me delete record successfully. Thanks


Run-time error '91'

Object variable or with block variable not set

pic ===>delete error


Option Compare Database

Private Sub cmdSearch_Click()
    Dim strStudentRef As String
    Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.

    If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
        MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
    Exit Sub
End If

'Performs the search using value entered into txtSearch
'and evaluates this against values in customerno

    DoCmd.GoToControl ("customerno")
    DoCmd.FindRecord Me!txtSearch

    strStudentRef = customerno.Text
    strSearch = txtSearch.Text

'If matching record found sets focus in customerno and shows msgbox
'and clears search control

    If strStudentRef = strSearch Then
        MsgBox "Match Found For: " & strSearch, , "Congratulations!"
        txtSearch = ""

    'If value not found sets focus back to txtSearch and shows msgbox
            MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
            , "Invalid Search Criterion!"
    End If
End Sub

Private Sub Command14_Click()
'''On Error GoTo Err_CmdAdd_Click
    '''Me.DataEntry = True
    '''Me.CmdFilter.Visible = False
    '''Me.CmdShowAll.Visible = True
   '''DoCmd.GoToRecord , , acNewRec
   If DCount("*", "Customer") = 0 Then
        Me.customerno = 1

        Me.customerno = DMax("Customerno", "Customer") + 1
        Me.customerName.Value = " "
   End If

    '''Exit Sub

    '''MsgBox Err.Description
    '''Resume Exit_CmdAdd_Click
End Sub

Private Sub cmdDelete_Click()

Dim x As Variant

x = MsgBox(" You are abut to delete " & Me.customerName & " from this table - proceed ? ", vbOKCancel)

If x = 1 Then

With myRS


End With

End If

End Sub

All times are GMT -4. The time now is 06:26 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.