0
votes

I have 2 forms. 1 subform.

The main form, MainFormF, has a subform which is hooked up to a query that takes data from a table and outputs it into a datasheet. Lets call this subform MainSubformF.

The 2nd form is loaded from a button on MainFormF. It has 2 buttons, previous and next. How do I attach these buttons to switch the next/previous record HIGHLIGHTED in the datasheet subform?

Highlighted record

As you can see, that is what it looks like highlighted. It turns blue, if you didn't know.

The code I currently use but doesn't switch the selected records at all is this:

Private Sub Command65_Click()
On Error GoTo new_Err

Forms!MainformF!MainSubformF.SetFocus 'sets the focus to MainSubformF
DoCmd.RunCommand acCmdRecordsGoToNew
new_Err:
End Sub

For the button to open up the More Info form, it takes information from a text box (lets name it InfoTxt) with this as it's control source:

=[MainSubformF].[Form]![ProjectID]

I am thinking I can do something with that variable, like add +1 to it so when the button is clicked it adds +1 to the ProjectID? I don't think that will work now that I am typing this out, but I'll keep this here in case I am right... though I am thinking further into it and ProjectID's aren't always +1, as in case a record was deleted it may go 1,2,3,5,6 and if you get to 3 then click next it'll do nothing as it'll go to 4 not 5.

1

1 Answers

0
votes

I simply don't have time to write out a complete answer, but Dev Ashish is a well-respected developer in the Access community and he devised a way to determine which records have been selected. My guess is you'll need to bookmark them somehow. Start with this Sub that Dev wrote:

Determine selected records in datasheet view