Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2005, 10:52 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with adding deleting records in bounded

Hi guys i a have bounded form that supposed to update/add and delete records from customers table. But it is acting very weried when i try to use it. For example in the pic below it shows my form trying to
add a new record number 8 .

http://i5.photobucket.com/albums/y18...oaddrecord.jpg

After i added new record and if i press the button to bring me to first record i see my new record added to begining of list and if i press button to take me to last record which is number 8 it shows its customername value as blank! I be happy if some one help me fixt this strange problem. Also the first record in the db get delete with new record!

http://i5.photobucket.com/albums/y18...ngrecords1.jpg ( value in table customer before adding new record)


http://i5.photobucket.com/albums/y18...howsblank2.jpg


http://i5.photobucket.com/albums/y18...newrecord3.jpg ( vlaus in table customer after adding new record .first record get deleted with out my intention!)

Now if i try to delete a record. should i number all the records or not ? I be happy if some one show me how to solve this problem as well.Thanks

http://i5.photobucket.com/albums/y18...edeleting4.jpg ( values of customer table before deleting record)


http://i5.photobucket.com/albums/y18...rdeleting5.jpg

(values of customer table after deleting records)

my code
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()

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
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
 
Old July 30th, 2005, 02:42 AM
Friend of Wrox
 
Join Date: Jul 2005
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This image:

http://i5.photobucket.com/albums/y18...howsblank2.jpg

is blank because it is a new record, and creating record 8.

This is not adding a record:
http://i5.photobucket.com/albums/y18...oaddrecord.jpg

Look at the bitton with >* for add record. If it is grayed out, then you are on a new record.

I could not follow what is going on.





Boyd
Access Based Accounting/Business Solutions developer.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Duplicate Records BrianWren Pro VB Databases 1 February 22nd, 2008 01:30 PM
Deleting all the records in a table suthaharmca Beginning VB 6 4 January 2nd, 2008 06:14 PM
Problem deleting records from a table ghall202 Access 4 March 2nd, 2007 03:58 PM
Deleting duplicate records ninel SQL Server 2000 3 June 14th, 2006 02:12 PM
Problem with bounded form query method Access 0 June 23rd, 2005 12:01 PM





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