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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update form and subform 1

Status
Not open for further replies.

TrekBiker

Technical User
Nov 26, 2010
334
GB

I'm using s Client form with a Jobs subform. The subform has a command button to launch a second form whose source contains fields from both the Client and Jobs form for the current Client/Job combination.

When adding a new client or a new job for an existing client, launching the second form causes it to open to a blank record. The data clearly isn't being updated until the Client form is closed and reopened.

How can I correct this? Have tried requerying both the Client form and Jobs subform but this makes the Client form jump to the first record in its data source.
 
Try a
me.dirty = false
before opening the pop up.

to do a requery and stay in place you do something like.

Code:
dim somePrimaryKey as long ' or your data type
somePrimaryKey = me.someField
me.requery
me.recordset.findfirst "somefield = " & me.somePrimarykey

Actually you requery and return to that record
 

Okay thanks, nice pointer.

I've added this to the command button that launches the second form from the subform and it works fine.

Dim lngID As Long
Dim rst As DAO.Recordset
lngID = JobID

Me.Requery

Set rst = Me.RecordsetClone
rst.FindFirst "[JobID] = " & lngID
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
End If
rst.Close

Set rst = Nothing

Much appreciated.
 
Never understood the purpose of that code, but See it all the time.
return the clone, find a record, get a bookmark, move to the bookmark in the recordset

Code:
 Set rst = Me.RecordsetClone
 rst.FindFirst "[JobID] = " & lngID
 If Not rst.NoMatch Then
 Me.Bookmark = rst.Bookmark

Same as simply doing
Code:
me.recordset.findfirst "[JobID] = " & lngID
simply move to the record or stay in place if record not found.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top