PDA

View Full Version : Move to a specified record on a form



KeefyBoy
07-19-2007, 05:46 AM
Hi

I have a calculated parameter that I want to use to move an open form to display the record relating to that parameter

e.g. ParamID= 2 move the form to display where CustID=ParamID

The form is already open as I want to use it to capture the initial value that I use to work out ParamID

Thanks

OBP
07-26-2007, 05:56 AM
KeefyBoy, have you solved this problem yet?
if not can you give an example of how you want it to work?

KeefyBoy
07-26-2007, 06:19 AM
I've done a very dirty solution, I use docmd.gotorecord to goto the first record, then test the value of the ID against my calculated one.

then I goto the next and re-test until I find the correct one.

I'm sure this will grind to a halt given any sizable datam but it works for now.

Ideally I would use a gotorecord type command that can accept a parameter to specify which record, not just "next", "first" etc

OBP
07-26-2007, 06:27 AM
The docmd.gotorecord has an actual Goto Record function, so if you know the record number that you want then you can go straight to it, is that what you want to do?
DoCmd.GoToRecord acDataForm, "Employees", acGoTo, 7
DoCmd.GoToRecord acDataForm, "Employees", acGoTo, Variablename
where Variablename is a dimensioned VBA Integer or Double variable holding the record number

You can also use the Record set version of the same thing
If it is a value that you are searching for you can use the Recordset FindFirst, FindNext, FindLast functions to find them.

KeefyBoy
07-27-2007, 04:25 AM
How do I find out the position of the record? I have looked at

.RecordCount
.AbsolutePosition
.CursorLocation

but none seem to return the correct value

OBP
07-27-2007, 05:49 AM
.Bookmark