Invisible Forms

  • Thread starter Thread starter Scott Matheny
  • Start date Start date
S

Scott Matheny

I have code in an afterupdate event of a text box that
changes the visibility of two seperate subforms on the
page. This, however, isn't useful in the afterupdate
section because the field must change to execute its
code. What section can I put my code in to have it run
when I open the database or just scroll to the next record
without changing anything?
 
The OnCurrent even fires when you scroll from one recor to the next.

If the visability of these items depends on some factor of the current
record, I would put my test in the OnCurrent.

Rick B


I have code in an afterupdate event of a text box that
changes the visibility of two seperate subforms on the
page. This, however, isn't useful in the afterupdate
section because the field must change to execute its
code. What section can I put my code in to have it run
when I open the database or just scroll to the next record
without changing anything?
 
You should not attach it to any button. You would attach it to the FORM's
OnCurrent event. This code will fire everytime you move from one record to
another.

Rick B


This didn't work. Does it matter what button I attach the
code to?
 
Here is the code for my form that does pretty much the same thing you are
trying to do...



Private Sub Form_Current()

If [Assignment] Like "CNV*" Then ' If the current record is
a data conversion
Me!TabCtl80.Pages(1).Enabled = True ' enable the data conversion
tab.
Else
Me!TabCtl80.Pages(1).Enabled = False ' Otherwise disable it
End If

If [Assignment] Like "FIN*" Then ' If the current record
is an F&I
Me!TabCtl80.Pages(2).Enabled = True ' enable the F&I data tab.
Else
Me!TabCtl80.Pages(2).Enabled = False ' Otherwise disable it
End If

End Sub






You should not attach it to any button. You would attach it to the FORM's
OnCurrent event. This code will fire everytime you move from one record to
another.

Rick B


This didn't work. Does it matter what button I attach the
code to?
 
My code works fine in the AfterUpdate event of my text
box, but I have to actually change the content of a the
field to make the code fire. However, just moving my code
to Sub Form_OnCurrent() does not work. What am I doing
wrong?
 
perhaps when the field loses the focus and moves to the next field?
LostFocus
it could fire then, regardless of changes (or lack of them)

DubboPete
 
Ok, here's the code that finally worked perfectly, just in
case anyone else was sitting on the edge of their seats
waiting for this thread to resolve...

Sub Form_Current()
If Text13.Value = "Tensile" Then
Forms![TestListFMW]![TensileData].Visible = True
Else
Forms![TestListFMW]![TensileData].Visible = False
End If
If Text13.Value = "Fatigue" Then
Forms![TestListFMW]![FatigueData].Visible = True
Else
Forms![TestListFMW]![FatigueData].Visible = False
End If
End Sub
 
My guess would be that your subform is not really moving between the various
records. On a form that just displays one single record, the code should
work fine. I have never tried it in a subform.

Rick B


My code works fine in the AfterUpdate event of my text
box, but I have to actually change the content of a the
field to make the code fire. However, just moving my code
to Sub Form_OnCurrent() does not work. What am I doing
wrong?
 
Whew.

Glad you got it to work!!

Rick B


Ok, here's the code that finally worked perfectly, just in
case anyone else was sitting on the edge of their seats
waiting for this thread to resolve...

Sub Form_Current()
If Text13.Value = "Tensile" Then
Forms![TestListFMW]![TensileData].Visible = True
Else
Forms![TestListFMW]![TensileData].Visible = False
End If
If Text13.Value = "Fatigue" Then
Forms![TestListFMW]![FatigueData].Visible = True
Else
Forms![TestListFMW]![FatigueData].Visible = False
End If
End Sub
 
Back
Top