Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Download:

Datei 1: 2017-03-28 Goto Record.zip

 

 

How to set the current record in a MS Access data sheet as a subform to a specific position?

 

Task: I want to set the data record in a subform to a specific position by using vba command.

 

 

Subject: vba, Recordset, currentrecordset, RecordsetClone, Bookmark, Goto, GotoRecordset

 

    '*move current recordset to row with ID=10

 

    '< get Datasheet Recordset >

    Dim rec As Recordset

    Set rec = ctlSubForm.Form.Recordset

    '</ get Datasheet Recordset >

   

    '< goto Recordset visible >

    rec.FindFirst "ID=10"

    '</ goto Recordset visible >

 

 

When you run the Form.Recordset.FindFirst, the record is automatically set to the position of the hit and quasi marked.

However, this does not correspond to a real mark or select (Bookmark)

 

Executing rec.FindFirst "User = 'AA'" will search for another column.

 

 

Data structure:

The exercise table has only two columns or fields: ID and User.

 

Subform:

In order to display controls like the two upper buttons and at the same time a data table as a view, you can embed a subform in a main form which contains the data table in the subform.

The data table corresponds to a form whose default view is set to data sheet.

 

 

 

Vba Code for moving the current record in a form data sheet

Option Compare Database

Option Explicit On

 

Private Sub btnGoto11_Click()

    '-------------< btnGoto11_Click() >-------------

    '*move current recordset to row with ID=10

 

    '< get Datasheet Recordset >

    Dim rec As Recordset

    Set rec = ctlSubForm.Form.Recordset

    '</ get Datasheet Recordset >

   

    '< goto Recordset visible >

    rec.FindFirst "ID=10"

    '</ goto Recordset visible >

    '-------------</ btnGoto11_Click() >-------------

End Sub

 

 

 

Private Sub btnGotoAA_Click()

    Dim rec As Recordset

    Set rec = ctlSubForm.Form.Recordset

   

    rec.FindFirst "User='AA'"

End Sub

 

 

In Visual Basic for Application ...

Both button events

Mobile

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de