Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 19th, 2005, 04:37 PM
Friend of Wrox
 
Join Date: Mar 2005
Location: , , .
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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


Code:
Run-time error '91'

Object variable or with block variable not set
http://i5.photobucket.com/albums/y18...eleteerror.jpg
pic ===>delete error


Code:
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!"
        Me![txtSearch].SetFocus
    Exit Sub
End If
'---------------------------------------------------------------

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

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

    customerno.SetFocus
    strStudentRef = customerno.Text
    txtSearch.SetFocus
    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!"
        customerno.SetFocus
        txtSearch = ""

    'If value not found sets focus back to txtSearch and shows msgbox
        Else
            MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
            , "Invalid Search Criterion!"
            txtSearch.SetFocus
    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
   Else

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

'''Exit_CmdAdd_Click:
    '''Exit Sub

'''Err_CmdAdd_Click:
    '''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

.Delete
.MoveFirst


End With

End If

End Sub
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I delete a record from a form? dstein4d Access VBA 8 August 24th, 2007 12:09 PM
Display the current record in textbox (form) Vassala Access 2 January 25th, 2007 05:05 PM
print current record on another form jcellens Access 7 February 14th, 2006 02:01 PM
print current record in a form mjuliao Access 1 November 15th, 2005 08:57 AM
Error updating record in bounded form method Access 0 June 19th, 2005 05:31 PM



All times are GMT -4. The time now is 09:20 AM.


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