Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hidden Button 2

Status
Not open for further replies.

rkd

Technical User
Mar 5, 2000
8
GB
I have the following code.<br>
<br>
<br>
Private Sub Form_Current()<br>
<br>
' If value in Status text box is Equal to &quot;FORWARDER&quot; or &quot;HAULIER&quot;<br>
' text box is display.<br>
<br>
If (Me!StatusName) = &quot;Forwarder&quot; Or (Me!StatusName) = &quot;Haulier&quot; Then<br>
Me!Available.Visible = True<br>
Me!MoreDetails.Visible = True<br>
<br>
' Otherwise, display Box is not visible<br>
<br>
Else<br>
Me!Available.Visible = False<br>
Me!MoreDetails.Visible = False<br>
End If<br>
<br>
<br>
<br>
End Sub<br>
<br>
<br>
When a new record is entered or an old record edited this button will not appear/disappear until you move to the next record and back, by selecting the command remove filter it does work. has anyone got any idea how I can add a remove filter to the bottom of this sum so that it appears as soon as the correct value is selected?<br>
<br>
Many thanks<br>
<br>
J<br>

 
You need to put Me.requery in the AFterUpdate of the form<br>
--Jim
 
I've tried that it didn't work!<br>
<br>
The names &quot;Forwarder&quot; & &quot;Haulier&quot; are in a combo box I've tried placing refresh in the above code but to no avail. I am sure it is possible, there is no doubt something simple I am missing.<br>
<br>
Thanking you all in advance<br>
<br>

 
Are yo sure the case is correct, ie, &quot;Forwarder&quot; &lt;&gt; &quot;forwarder&quot;. Also, the AFterUpdate will only work when the record is saved, ie, moving to a subform or cycling past the last tab in tab order. If this is only in a combo box, then just put the .enable/.disable in the afterupdate ot the combo box--but keep it in the current event also, for existing records as you browse. <br>
<br>
At last resort, if the afterupdate thing doesn't seem to work, put a breakpoint there and make sure the code flows there. Sometimes, if you put code directly into a form module, ie not through the Properties box and clicking 'build event', the [Event Procedrue] tag never gets put in the Properties box and the code is never run on the event. If you just type &quot;[&quot; in that event, then this tag will appear.<br>
--Jim
 
Thanks Jim<br>
<br>
<br>
I copied the above code to the Combo box AfterUpDate and it all works find.<br>
<br>
I don't understand why I need the same code in both places, I tested it and one does not work without the other, but any way I am happy that at last it does what I want.<br>
<br>
Many thanks<br>
J
 
J, you need it in both places because you want it to be triggered in case of 2 separate events: whenever you go to a new record (OnCurrent), and whenever you make a change to that field on the current record (OnUpdate). <br>
<br>
Jim, I've always duped my code for these things. I thought .Requery was just supposed to rerun the underlying query. Maybe I should try .Refresh or .Repaint?
 
elizabeth,<br>
The way I've used it is that .refresh refreshes the controls on the form with the existing recordset, showing any changes based on the current query or table; requery reruns the query underlying, showing changes based on the criteria--which either the criteria itself may have changed or data in a field considered in criteria changed, etc (so there is some overlap here); and repaint updates just the graphical stuff on the form if, say a modal box had covered an area and it left a ghost blank space. I could be off a bit but this has been effective for me.<br>
--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top