go specific record

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Go to a specific record

Go to a specific record

resolvedResolved · 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

RE: Go to a specific record

You have been helpful! :)

 

Training courses

 

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Create a custom Close button on a Form

By 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.



Sometimes Access needs to follow certain procedures or events as users close a Form (such as automatically opening another Form perhaps). So it is often a good habit to create a custom Close button on a Form for everyone to use, rather than the standard closing cross.



To create a custom Close button:

1) In Form Design View, draw a Command Button onto the Form.

2) Use the Command Button Wizard to select Form Operations under Categories, and Close Form under Actions.

3) Choose Finish.



Access then creates the button and code to close the form for you. You can add any extra code that needs to run as the Form closes to the same Close procedure.



However, the creation of a custom Close button is pointless if the closing X in the top right-hand corner of the Form remains active. To make the closing X inactive, open the Form Properties box then on the Format tab set the Close Button setting to No. This will grey out the closing X leaving it visible, but inactive.



View all Access hints and tips


Server loaded in 0.1 secs.