MyODBC and Access - one step closer
Ok this is really bugging me (because I just can't figure it out). I'm using Access with MyODBC (an ODBC driver).
Every time I click the new record button, enter some data in and proceed to enter some more data in a sub form in the same form I get '#Deleted'.
Now I've managed to get around this in existing records by creating a subroutine that instances a Timer and issues a Requery:
This seems to do the trick for existing records (where I know what the unique identifier is), I use this at the end of all sub forms (in AfterUpdate) but for new records I can't do this because I don't know what the new unique ID will be. Is there anyone out there who can help me on this one. I can show you the database if needs be.
Is there a VBA way of... when the user presses the New Record button, I can create the new record (with nothing in it), save it, and then open it up for the user to edit (thus letting me know what the newly created unique ID is)?
I need the access equivalent of the PHP function:
I guess.
Ok this is really bugging me (because I just can't figure it out). I'm using Access with MyODBC (an ODBC driver).
Every time I click the new record button, enter some data in and proceed to enter some more data in a sub form in the same form I get '#Deleted'.
Now I've managed to get around this in existing records by creating a subroutine that instances a Timer and issues a Requery:
Code:
Sub QueryTimer(tmpid As Integer, tmpForm As Form)
Dim PauseTime, Start, Finish, TotalTime
PauseTime = 0.25 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
'DoEvents ' Yield to other processes.
Loop '
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
DBRequery tmpid, tmpForm
End Sub
Public Sub DBRequery(tmpid As Integer, tmpForm As Form)
If SuppressMsgbox = False Then MsgBox tmpid
If tmpid = 0 Then Exit Sub
tmpid = tmpid
tmpForm.Requery
DoCmd.ApplyFilter , "FacilityID = " & tmpid
End Sub
This seems to do the trick for existing records (where I know what the unique identifier is), I use this at the end of all sub forms (in AfterUpdate) but for new records I can't do this because I don't know what the new unique ID will be. Is there anyone out there who can help me on this one. I can show you the database if needs be.
Is there a VBA way of... when the user presses the New Record button, I can create the new record (with nothing in it), save it, and then open it up for the user to edit (thus letting me know what the newly created unique ID is)?
I need the access equivalent of the PHP function:
Code:
$tmpID = mysql_insert_id();
Last edited: