Run Form_Current event (1 Viewer)

kirkm

Registered User.
Local time
Tomorrow, 09:09
Joined
Oct 30, 2008
Messages
1,257
Code:
Set r = Forms.Form1.Datasheet.Form.RecordsetClone
r.FindFirst "Prefix ='" & txtGoto.Text & "'"
If Not r.NoMatch Then
     Forms.Form1.Datasheet.Form.Bookmark = r.Bookmark
     Form_Datasheet.Form.Form_Current
End If
Set r = Nothing

The above moves to selected record in Form Datasheet. But it does not run Form_Current event.
The second to last line raises an error. I've tried different syntax but all fail.
So I suspect this is wrong - what would be the right way ?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:09
Joined
Oct 29, 2018
Messages
21,358
Where is this code located?
 

kirkm

Registered User.
Local time
Tomorrow, 09:09
Joined
Oct 30, 2008
Messages
1,257
It's in the Keydown event of a text Box on the main Form There's code before that but all it does is validate txtGoto.
However I've just got it working, using Arne's bolInitialize which must be true for the Current event to run. He has a routine
Code:
Public Sub thisSub()
    'set it to true so Current event can be called
    bolInitialized = True
    Call Form_Current
End Sub

So my whole routine now is (and I suspect ok, but always ready to improve it):-

Code:
Private Sub txtGoto_KeyDown(KeyCode As Integer, Shift As Integer)
    'jump to Prefix
    Dim r As DAO.Recordset
    If KeyCode = 13 Then
        If InStr(txtGoto.Text, "_") > 0 Then
           If DLookup("Prefix", "tblMain4", "Prefix ='" & txtGoto.Text & "'") > "" Then
                cboYear = FourDigitYear(txtGoto.Text)
                Select Case Left(txtGoto.Text, 2)
                    Case "SM", Is < 52
                        Grid = 4
                    Case "LP"
                        Grid = 3
                    Case "EP"
                        Grid = 2
                    Case Else
                        Grid = 1
                End Select
                ResetDatasheet
                Set r = Forms.Form1.Datasheet.Form.RecordsetClone
                r.FindFirst "Prefix ='" & txtGoto.Text & "'"
                If Not r.NoMatch Then Forms.Form1.Datasheet.Form.Bookmark = r.Bookmark
                Me.Datasheet.Form.thisSub
                Set r = Nothing
           End If
        End If
    End If
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:09
Joined
Oct 29, 2018
Messages
21,358
Okay. Glad to hear you got it sorted out. Cheers!
 

Users who are viewing this thread

Top Bottom