Wrox Programmer Forums
|
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 May 28th, 2004, 02:27 PM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default db help

I have a database that has a few.. erm.. issues.

First, it will let me edit exisiting records in the form, but wont let me add new ones.

If someone would help me with this, Id be grateful.

I can post the db if needed.



 
Old May 28th, 2004, 02:56 PM
Authorized User
 
Join Date: Jun 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If this is an access project then you need to go back to the table which is used as the record source for the form and add a primary key to an existing field (e.g. EmployeeID) or add a new ID field and put that as the primary key.

slypunk
 
Old May 28th, 2004, 03:02 PM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

All the tables involved do have primary keys set.

:( this is frustrating


 
Old May 28th, 2004, 06:42 PM
Authorized User
 
Join Date: Jun 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mydnyght
 All the tables involved do have primary keys set.

:( this is frustrating


I had a similar problem. What I did was create my own navigation buttons and then wrote a code in the Form_Current as follows:


Private Sub Form_Current()

Dim recClone As ADODB.Recordset

'Make a clone of the recordset underlying the form so
'we can move around that without affecting the form's
'recordset

Set recClone = Me.RecordsetClone

'If we are in a new record, disable the NEXT button
'and enable the rest of the buttons

If Me.NewRecord Then
    cmdFirst.Enabled = True
    cmdPreviousRec.Enabled = True
    cmdNext.Enabled = False
    cmdLast.Enabled = True
    cmdNew.Enabled = True
    Exit Sub
End If

'If we reach here, we know we are not in a new record
'so we can enable the NEW button if the form allows
'new records to be added
If recClone.RecordCount = 0 Then
    cmdFirst.Enabled = False
    cmdNext.Enabled = True
    cmdPreviousRec.Enabled = False
    cmdLast.Enabled = False
Else

    'If there are records, we know that the FIRST and
    'LAST buttons will always be enabled, irrespective
    'of where we are in the recordset
    cmdFirst.Enabled = True
    cmdLast.Enabled = True

    'Synchronize the current pointer in the two recordsets
    recClone.Bookmark = Me.Bookmark
    'Next, we must see if we are on the first record
    'If so, we should disable the PREVIOUS button
    With recClone
        .MovePrevious
        cmdPreviousRec.Enabled = Not (recClone.BOF)
        .MoveNext

    'and then check whether we are on the last record
    'If so, we shoudl disable the NEXT button
        .MoveNext
        cmdNext.Enabled = Not (recClone.BOF)
        .MovePrevious
    End With
End If

'And finally close the cloned recordset
recClone.Close

End Sub

After doing this I was able to navigate through the records and also add records. Hope this helps.

slypunk
 
Old May 31st, 2004, 11:32 AM
Authorized User
 
Join Date: May 2004
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Go the Form Properties.
On the tab for Data,
Change "Allow additions" from No to Yes





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to transform an MDF db into a permanent db? hertendreef SQL Server 2005 2 April 10th, 2007 03:57 PM
Finding the DB Sailor.mdb of Beginning ASP DB book anna Classic ASP Databases 2 August 5th, 2006 01:13 PM
Converting Access DB to Online DB eyal8r Access 5 December 6th, 2004 05:22 AM
access db to sql server db mikersantiago Classic ASP Basics 4 November 16th, 2004 03:33 AM
Synchronizing web db with our master db sunny25 Classic ASP Basics 0 October 17th, 2003 09:16 AM





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