continuous form event to hide line (2 Viewers)

cpampas

Registered User.
Local time
Today, 08:40
Joined
Jul 23, 2012
Messages
218
In a continous form is it posible to make visible a line, everytime IDMov changes ?
something like this, but I am not clear on what event of the form, where the code would be triggered

Code:
If Nz(Me.txtPreviousid, "") = Me.idMov Then
        Me.Line5.Visible = False
    Else
        Me.Line5.Visible = True
    End If
    Me.txtPreviousid = Me.idMov
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:40
Joined
May 7, 2009
Messages
19,245
you try to put it in the Detail's Paint event.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:40
Joined
Feb 19, 2013
Messages
16,614
Suspect you need to use conditional formatting as your code will apply to all instances of the line

use a text box instead, sized to look like a line

call the text box something like txtCurrent and modify your code to

txtCurrent =idMov

and conditional formatting would be

expression is ….[ IdMov]=[txtcurrent]

set the conditional back colour to whatever you want and the line text box back colour to the same as the detail back color
 

nector

Member
Local time
Today, 18:40
Joined
Jan 21, 2020
Messages
368
On a continuous form its quite trick unless you want to limit the number of lines in the subform then use the code below:

Code:
Private Sub Form_Current()
On Error GoTo Err_Handler
LimitRecords Me, 1 'Allow at most 1 record
Exit_Form_Current:
Exit Sub
Err_Handler:
MsgBox Err.Number & Err.Description, vbExclamation, "Error"
Resume Exit_Form_Current
End Sub
 

cpampas

Registered User.
Local time
Today, 08:40
Joined
Jul 23, 2012
Messages
218
ArnelGH , in the details paint event i cannot set the value of the textbox

Cj_London, the approach of mimic a line with a textbox is great, but i still dont know what event i put txtCurrent =idMov
 

Mike Krailo

Well-known member
Local time
Today, 11:40
Joined
Mar 28, 2020
Messages
1,044
Might want to ask Eugene-LS about his method HERE
1695661816521.png
 

cpampas

Registered User.
Local time
Today, 08:40
Joined
Jul 23, 2012
Messages
218
the idMov gotfocus event will notwork for me since records are not being populated manualy.
I ended up updating the field txtPrevious, on opening the form, and after that a conditional format of the textbox that looks like a line
Thanks for your help

Code:
Private Sub Form_Open(Cancel As Integer)


    Dim rs As DAO.Recordset
    Dim previous As String
    


    Set rs = Me.RecordsetClone
   rs.MoveFirst
 
   Do While Not rs.EOF
        With rs
            If .BOF Then
                 .Edit
                     !txtPrevious = -1
                .Update
            Else
                .Edit
                    !txtPrevious = previous
                .Update
            End If
      previous = rs.Fields("idMov")
     .MoveNext
  End With
  Loop
    
    Set rs = Nothing
End Sub
 

Users who are viewing this thread

Top Bottom