Return to Website

MS Access

Computers at Large brings MS Access Forum for you to ask questions, answer questions or look up solutions

MS Access
Start a New Topic 
Re: OpenForm opens with garbage

You just need to put in a Refresh statement.

--- --- --- --- --- --- --- --- ---

Replying to:

My cascading forms seem to have hit whitewater!

A read only bound form has this button to create a New Record (autonumber: [CPID]), then open it with a New Form for Editing. Works great, except it fills with random data, unrelated to the index key or the bound [Patient ID #].

Do I need a Refresh, Requery or Repaint, or whatever? My assumption was that the rst.Update would get filed before the new form fetched the data.

Here is the CODE snippet:

Private Sub cmdCareNew_Click()

On Error GoTo Err_cmdCareNew_Click

Dim dbs As Database, rst As Recordset, newCPID As Long

Set dbs = CurrentDb

Set rst = dbs.OpenRecordset("tblCareData", dbOpenDynaset)


rst![Patient ID #] = Me![Patient ID #]

rst![ProbItem] = Me![ProbItem]

rst![InitDate] = Date

rst![RevDate] = Date

rst![SysDate] = Now()

rst![GoalList] = ""

rst![ActionList] = ""

rst![Version] = 2

rst![IDTitem] = 1


newCPID = rst![CPID]


Set dbs = Nothing

DoCmd.OpenForm "frmCareEdit", , , "[CPID]=" & newCPID


Exit Sub


MsgBox Err.Description

Resume Exit_cmdCareNew_Click

End Sub