Can't query a record after adding it on a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,
I have a form where the user enters a new record. In the form's AfterUpdate
event, I create recordset that retrieves the same record that was added. The
problem is that the record count is 0 which means it's not being found.
For example:
I add a medical visit on the form (visitID = 33). Then I run the following
code in the form's AfterUpdate event to retrieve medical visit 33:
SQL = Select statement......
SQL = SQL & " WHERE VisitID = " & VisitID

Set OConn = OpenConn()
Set rstInfo = New ADODB.Recordset
rstInfo.ActiveConnection = OConn
rstInfo.Open (SQL)

I was thinking that the record was truly saved yet so I put in the
acCmdSaveRecord in the DoCmd statement and I also tried using the SendKey
statement to actually save the record before the query is done. I even tried
added the code into the forms AfterInsert event. Nothing is working. If I
were to go back in the same screen and do an update, the record is accessible.

Does anyone have any ideas? Shouldn't the record be available for
retrieval? Is it a locking issue? Any suggestions would be helpful. Thank
you.
Debbie
 
I usually set the 'Dirty' property to False to assure that changes to a
record are committed back to the recordsource.
 
Back
Top