Kamis, 26 Januari 2017

Re: [MS_AccessPros] Inventory database - I cannot add a new vendor using form

 

Jorge-


Well, that's a long-standing bug.  There should be this code in the Before Update event of the form:


Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim varID As Variant
    ' Provide VendorD on new record
    If Not Me.NewRecord Then Exit Sub
    ' Get the previous high ID
    varID = DMax("VendorID", "tblVendors")
    ' Get a null if this is the first one
    If IsNothing(varID) Then
        Me.VendorID = 1
    Else
        Me.VendorID = varID + 1
    End If
    
End Sub


John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Jan 26, 2017, at 10:23 PM, muralles_r12@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



    

Hi Folks, I hope you are well. Actually, I should say hi John, thanks for always helping out.


I am playing around with the inventory database that comes with your book.


I am trying to add a new vendor using the form.


The form has a vendor ID which I cannot edit, It thought it was an auto number, but it is not.


The vendor ID is the primary key.


When I add a new vendor it says it requires the vendor ID.


Why is it that I am not able to select it and create it?


I thought the application would created automatically, but it does not.


Thanks for the help.


Jorge Muralles






__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar