Results 1 to 5 of 5

Thread: Problem with adding deleting records in bounded

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow 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

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Problem with adding deleting records in bounded

    How come your deleting by code instead of the delete button that you can add to the forms record navigator. It usually is next to
    the new record button.

    Also if your numbering your field you should use an Autonumber field if your not already.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow Re: Problem with adding deleting records in bounded

    Quote Originally Posted by RobDog888
    How come your deleting by code instead of the delete button that you can add to the forms record navigator. It usually is next to
    the new record button.

    Also if your numbering your field you should use an Autonumber field if your not already.
    thank u for u reply. Well i do not know how to add that delet button next to record locator. Could u tell me how i can add it. Furthermore is there a way to use add button in right side of record locater so that once it is clicked it auto incrment value of customerno ? I do not want to change the designe of my db to make a field autonumbe. if i delete a record should i re number all the records ?I be happy if u help me fix this problem.


    note: more thing my tables are linked to sql server tables.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Problem with adding deleting records in bounded

    Its in the Form View toolbar when the form is displayed. There are buttons for new/delete/sort up/sort donw/etc.
    Since your tables are linked to a SQL server you can not add a autonumber filed in access. You need to add it in SQL. The field of
    concern could be changed to a Identity field data type an enter the seed value and increment value.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow Re: Problem with adding deleting records in bounded

    Quote Originally Posted by RobDog888
    Its in the Form View toolbar when the form is displayed. There are buttons for new/delete/sort up/sort donw/etc.
    Since your tables are linked to a SQL server you can not add a autonumber filed in access. You need to add it in SQL. The field of
    concern could be changed to a Identity field data type an enter the seed value and increment value.
    Thanks for u reply. is there a way to drag that button and place it inside the form so that user see it all the time and not looing for it.i be happy to get your help here.Furthermore, do not u think it is possible to auto incrment in code ? one more thing what will happend if i am using auto increment and i delete a record? does the system will auto number all the records or should i do some thing about it ?thank u and looking forward to your reply.Thanks

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