Switch visible Fields choosing from Listbox

Marinus

I'm learning... :)
Local time
Today, 22:22
Joined
Jun 16, 2010
Messages
140
Hi Guys,
Happy New Year to all, and a fresh question to go with the best wishes.

On frmPayment I manage the purchase and sale of scrap, I choose records from a listbox [List210], most transactions are buying, sometimes there is a sale. A operator has to enter / override the [buyprice] or [saleprice].

To avoid human error in input, who would know a way for me to hide the field that is no used, the switch condition is a yes/no field called [sale]
 
Something along the lines of the following should do the trick;
Code:
If Me.Sales = True Then
     Me.buyprice.Visible = False
     Me.saleprice.Visible = True
Else
     Me.buyprice.Visible = True
     Me.saleprice.Visible = False
End If
This code would need to go in the form's On Current event and well as the On Click event for the Check Box Sales.
 
Something along the lines of the following should do the trick;
Code:
If Me.Sales = True Then
     Me.buyprice.Visible = False
     Me.saleprice.Visible = True
Else
     Me.buyprice.Visible = True
     Me.saleprice.Visible = False
End If
This code would need to go in the form's On Current event and well as the On Click event for the Check Box Sales.

Thanks John, I was nearly there when I got your answer which works great, while trying I managed to come close to your solution. Only the fields wouldn't switch, as per your answer I put the code in the On Click event of the Check Box and then everything worked fine. Then I transferred code to On Click event of the Listbox and this worked fine as well.

Great Job.. Thanks for this solution.. :)
 
Thanks John, I was nearly there when I got your answer which works great, while trying I managed to come close to your solution. Only the fields wouldn't switch, as per your answer I put the code in the On Click event of the Check Box and then everything worked fine. Then I transferred code to On Click event of the Listbox and this worked fine as well.

Great Job.. Thanks for this solution.. :)

Just remember you will need this ALSO, as was noted earlier by JBB, on the form's ON CURRENT event so that when you move from record to record it will show the correct controls for the selection that is currently there. Otherwise it will stay on the last one selected regardless of what the current selection is on the form.
 
Just remember you will need this ALSO, as was noted earlier by JBB, on the form's ON CURRENT event so that when you move from record to record it will show the correct controls for the selection that is currently there. Otherwise it will stay on the last one selected regardless of what the current selection is on the form.

Thanks Bob, I started with the forms On Current like JBB mentioned and then did the click of the listbox.. Works great.. :)
 

Users who are viewing this thread

Back
Top Bottom