Steve R.
Retired
- Local time
- Yesterday, 23:23
- Joined
- Jul 5, 2006
- Messages
- 5,274
I was able to successfully transfer my magazine MS Access back-end to MYSQL. Basically everything worked well, except that I could not add new records in a sub-form. The sub-form is based on a query that uses two tables, each of which must be auto-incremented.
After making the final entry before going to the next new record, MYSQL reported the records of one of the tables as being "deleted". They weren't, the linking "value" was not copied, so the query failed.
Anyway, in searching the MYSQL forum, I found a post by Alan Parker that presented a solution to a similar failure to auto-increment.
He posted the following:
I modified that approach to:
So far it is working. Any additional thoughts on improving this solution?
Update: Still working. Ran across this helpful post on the need to have a time-stamp field: Access and MYSQL continuous form problem. Tested out, with the time-stamp field and it failed. Removed the time-stamp field and the Access front-end worked again.
After making the final entry before going to the next new record, MYSQL reported the records of one of the tables as being "deleted". They weren't, the linking "value" was not copied, so the query failed.
Anyway, in searching the MYSQL forum, I found a post by Alan Parker that presented a solution to a similar failure to auto-increment.
He posted the following:
I have assumed that the autonumber field is called Alan , just adjust this as neccessary for each form
On the Forms before insert event use.........
Alan = DMax("[Alan]", Me.RecordSource) + 1
Note the form recordsource has to be a table or query NOT a Select statement. If it is a select statement save the select statement as a query .. dead simple..
I modified that approach to:
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
Me.StoryIDNUM = DMax("storyidnum", "tblStoryList") + 1
Me.LinkIDNUM = DMax("linkidnum", "tblLinkedlist") + 1
End Sub
So far it is working. Any additional thoughts on improving this solution?
Update: Still working. Ran across this helpful post on the need to have a time-stamp field: Access and MYSQL continuous form problem. Tested out, with the time-stamp field and it failed. Removed the time-stamp field and the Access front-end worked again.
Last edited: