Refresh Display but stay on current Record (1 Viewer)

Len Boorman

Back in gainfull employme
Local time
Today, 12:16
Joined
Mar 23, 2000
Messages
1,930
Basically I have a Form with Sub form

I add soem data to sub form and then need to refresh the Main Form which will use sub form data in calculation.

That's basically okay using Me.Requery. All teh calcs work no problem

Problem is that this returns me to first record in the query results. Yes as expected result

Now I want to stay on the current record so I think I need something like

Detect record number as shown in navigation at bottom of form and hold as variable
Docmd.Requery
Docmd.GoToRecord where record number = navigation number.

Have seached but not found what I am looking for.

Would appreciate guidance on picking up teh record number as shown in navigation.

Thanks

len
 

namliam

The Mailman - AWF VIP
Local time
Today, 13:16
Joined
Aug 11, 2003
Messages
11,695
Try something like
Var = PrimaryKey
Requery
Findfirst where PrimaryKey = Var
 

BarryMK

4 strings are enough
Local time
Today, 12:16
Joined
Oct 15, 2002
Messages
1,350
Hi Len
I'm sure the mailman's elegant solution will be what you're looking for but just out of curiosity is there a reason why me.recalc won't work here?
 

Len Boorman

Back in gainfull employme
Local time
Today, 12:16
Joined
Mar 23, 2000
Messages
1,930
Barry

Will be trying Mailman's offer.

Your question. me.recalc or docmd.recalc sends you back to the first record.

I have a bunch of records. Could be anything from 1 to 1800 depending on criteria selected. Users are reviewing stock status as shown on the main form and then entering their actions on sub form.
Main form is not continuous cos of the amount of data so have Next and Previous record buttons

These actions could affect main form data calcs so need to refresh calcs on main form. Refresh only refreshes the view of the current data as held by the supporting query. I need to re-run query to update calculated fields and as a result of this the display is refreshed but back to first record. Thatis going to hack a few people off it they are at record 100 or so.

Tried just requery calculated fields but that sort of worked but again I could not get the display refreshed.

Strangely never come across this before but then again this is New Company and learn something new every day

Len
 

Len Boorman

Back in gainfull employme
Local time
Today, 12:16
Joined
Mar 23, 2000
Messages
1,930
mailMan

getting there

Dim Var As String

Infast _part is field on main form that represents the record I want to immediately return to after the requery

Var = Me.Infast_Part
Requery
DoCmd.FindRecord Var, , True, , True

This does not work because I think the Variable holding the Infast_Part is either not being set or is getting revised as a result of teh requery. No error messages so fancy it is being over written.

The GoToRecord requires an offset which is the "Record Number" That number taht is in the Navigation box. Searched but so far no clues on how to pickup this number

Len
 

namliam

The Mailman - AWF VIP
Local time
Today, 13:16
Joined
Aug 11, 2003
Messages
11,695
I never use docmd...

Dim rs as dao.recordset
Dim var as string 'Is your key a string??
var = Me.Infast_Part
Me.Requery
Set rs = me.recordsetclone
rs.FindFirst "Infast_part = '" & var & "'"
Me.bookmark = rs.bookmark
set rs=nothing
 

Len Boorman

Back in gainfull employme
Local time
Today, 12:16
Joined
Mar 23, 2000
Messages
1,930
Mailman

That hit the spot dead centre

Much appreciated assistance

Thank You

Len

PS Added to reputation but will not let me do it twice cos that's what it deserves
 
Last edited:

Users who are viewing this thread

Top Bottom