98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Access VBA Training and help » Go to a specific record
Go to a specific record
Resolved · High Priority · Version 2016
Manny has attended:
Access Intermediate course
Access Advanced course
Go to a specific record
I thought this would be quite a simple one, but is proving to be rather trouble some.
once a query has been refreshed i want the last record access to be the most recent record highlighted.
my code..
Dim strBookmark As String
Dim subfrm As Form_PriceByFundSubFormF
Set subfrm = Forms!PriceByFundF.PricingF.Form
Dim frm As Form_PriceByFundF
Set frm = Forms!PriceByFundF
strBookmark = subfrm.Form.CurrentRecord
frm.Refresh
DoCmd.GoToRecord acDataForm, , acGoTo, strBookmark
I got run time error 2498, an expression enter is the wrong data type. I tried making strBookmark as an integer as well but i have obtained the same error.
Please could you check? it must be something really simple but im not sure :(
Thanks, Manny
RE: Go to a specific record
Hi Manny,
Thank you for the forum question.
When you get the debug dialog box which line return the error?
Without knowing your database I assume that a record in the form is more than one column. A data variable can only store one information and not a whole record (arrays can store as many as you want).
To do what you want you will need to use ADO or DAO to move the cursor to point at the right record in the recordset.
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
RE: Go to a specific record
Hi jens, it errors on the DoCmd.GoToRecord. "An expression you entered is the wrong data type for one of the arguments".
You are correct there are multiple columns but i also tried the DAO.recordset but still had no luck. I believe the gotorecord should work but perhaps im using this incorrectly?
Manny
RE: Go to a specific record
Hi Manny,
Can you please let me know what you have stored in the variable strBookmark, when you get the error. Just open the Locals window when you get the error.
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
RE: Go to a specific record
Hi Jens,
Ive managed to correct it :) instead of using bookmark. i used this....
Dim strBookmark As Long
Dim subfrm As Form_PriceByFundSubFormF
Set subfrm = Forms!PriceByFundF.PricingF.Form
Dim frm As Form_PriceByFundF
Set frm = Forms!PriceByFundF
strBookmark = subfrm.Form.CurrentRecord
frm.Refresh
subfrm.Recordset.Move strBookmark
RE: Go to a specific record
Well done again Manny. I have not been very helpful, but I and happy that you get it right.
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
RE: Go to a specific record
Well done again Manny. I have not been very helpful, but I and happy that you get it right.
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Access tip:Create a custom Close button on a FormBy default, Forms that you create in Access have a full set of control buttons, that is, a title bar with Minimize, Maximize and Close buttons in the top right-hand corner and a Control Menu in the top left-hand corner. |