findrecord problem (2 Viewers)

Dirkvwaes

New member
Local time
Tomorrow, 00:06
Joined
Dec 2, 2025
Messages
4
Can somebody help me please!
I have two forms on my screen. One containing all the letters of the alphabet (in separate fields), and a second contains a list of names in alphabetical order. How do I jump to the first record in the second form whose first letter = the letter selected in the first form? I tried findrecord and gotorecord, but i always get an error

Private Sub voorletter_Click()
Dim reeksletter As String
reeksletter = Me!voorletter & "01"
Forms!keuzetitel.SetFocus
Forms!keuzetitel.FindRecord reeksletter, acAnywhere
End Sub

i get only an "appliction or object fault"
 
Can you please upload a zipped copy of your database, stripped to the bare essentials?

FindRecord is a method of the DoCmd object, not of the Form object. Your code currently does not compile, I presume (VBA window > Debug > Compile).
 
Here is one way another member did it.

Code:
    Me.RecordsetClone.FindFirst "[AAC] = 'A'"
    Me.Bookmark = Me.RecordsetClone.Bookmark
I assume you can work out your criteria for FindFirst?
Bear in mind that they were just using one form. That code was also on all their Alpha letter buttons, A, B, C etc, with just a simple change.
 
Eureca! The problem is solved, Many Thanks to tvanstiphout ,and especially Gasman with the right code to do the job. This forum is priceless!
I give here the code that works like a charm for me:

Private Sub voorletter_Click()
Dim reeksletter As String
Dim rst As Recordset
reeksletter = Me!voorletter & "01"
reeksletter = "[volgnr] = '" & reeksletter & "'"
Forms!keuzetitel.SetFocus
Set rst = Forms!keuzetitel.RecordsetClone
rst.FindFirst reeksletter
Forms!keuzetitel.Bookmark = rst.Bookmark
Forms!keuzetitel.Refresh
End Sub

explanation: the green form is a list wiyh all the seies of comics from my collection. When i click on a name, the series-form with that nummer opens (blue one) But because the list is very long, a second form opens also with existing subcategories of that comic. (hardcovers, mini...) Now i can go in a second to the wanted book.
 

Attachments

  • Knipselcomics.JPG
    Knipselcomics.JPG
    112.5 KB · Views: 16
Add this:

rst.FindFirst reeksletter
if not rst.NoMatch then
Forms!keuzetitel.Bookmark = rst.Bookmark

You always want to test the result of functions that can fail.
 
Last edited:
Note for future postings: please post code between CODE tags to retain indentation and readability - use </> icon on edit toolbar.
 

Users who are viewing this thread

Back
Top Bottom