|
My company has a database on SQL server. I am tyring to make an access interface that will make a lot of things easier. I cannot change the database structure or the field types.
I am trying to make a form where users can modify infromation in a 'notes' table. The notes table has three keys, PersonID, ClientID, and NoteID, the data Type for each of these is "text". I have everything working fine if the users modify an existing note, however I cannot figure out how to let users enter in a new record.
I crete a button and make some VBA code that uses the DoCmd.GoToRecord, "FormName", acNewRec command. I can then auto fill in the PersonId, and ClientID because that information is on the original form. However, NoteID seems to be a number that the SQL server auto generates.
What VBA code can I use to find what the next auto number should be?
I can find what I think is the highest current key by using:
AutoNum = DMax("NoteID", "dbo_PersonNotes")
But I do not know how to increment that number by one.
From memory, it seems like access will automatically insert the correct ID if the field type is set as "automumber" after the user enters in a new record. When I try it now I get an error "ODBC--call failed" then "You can't save this record at this time"
I have searched around a bit online but have not been able to find an anser. Any help is appreciated. Thanks
|