Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Virtual Records! 1

Status
Not open for further replies.

spruceni

Technical User
May 18, 2007
72
GB
Hi
I have created a form (not attached to a table) into which I get the user to enter some details. I then open a new record in the required table and write in the details. As follows-

' Adds a new record to a Recordset using the data on the new form

With rstAddAction
.AddNew
!ActionNumber = Me.ActionNumber
!ActionType = Me.ActionType
!StdClauseID = Me.StdClauseID
!NonConf = Me.NonConf
!RootCause = Me.RootCause
!Action = Me.Action
!Progress = Me.Progress
!AuditID = Me.AuditID
!LaboratoryID = Me.LaboratoryID
!BusinessManID = Me.BusinessManID
!RespPerson = Me.RespPerson
!RaisedDate = Me.RaisedDate
!ToQualityDate = Me.ToQualityDate
!ToBMDate = Me.ToBMDate
!FromBMDate = Me.FromBMDate
!ActTargetDate = Me.ActTargetDate
!ActCompDate = Me.ActCompDate
!FollowUP = Me.FollowUP
!QMSignOff = Me.QMClose
!FollowUp2 = Me.FollowUp2

.Update
End With
' Clean up recordsets
rstAddAction.Close
Set rstAddAction = Nothing
Set db = Nothing

I note when examining the running of this code using debug the record is not written directly to the table and at this stage of the code there is no new record in the table. The record only seems to appear once the Sub closes.


What I wanted to do is to open the newly saved record while still in the same Sub, with another form so that further data can be input but the record is not there to open.

How do I force the record to be written to the table when I do the .update command so at it appears in the table and I can then use it in another form.


Thanks for any help.
 





Close the recordset before your query from the other form.

Or use the recordset in the other form. Why query when you already have the data?

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Thank you for your reply. I thought I had closed the recordset after the update using
' Clean up recordsets
rstAddAction.Close
Set rstAddAction = Nothing
Set db = Nothing

It is then that I open another form using the record set from the table. This is the general edit form and is called from different parts of the programme. So there would not always be a recordset rstAddAction available.

I thought closing the record set would flush out the data to the table. Is there a refresh command that would do this?


Regards

Spruce
 
You may call the DoEvents function before opening the form.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top