0
votes

I have this continuous form "Results" built on a "Search" query in Microsoft Access and I want to show a hidden text field "Number" (with its Visible property initially set to False) depending on the value of one query result written in a "Type" combo box. My code is currently as follows:

Private Sub Form_Load()
If Me.Type="Reclamation" Then
Me.Number.Visible=True
Else: Me.Number.Visible=False
End If
End Sub

This does not seem to work, however the code does fine when triggered by a change event. Adding, changing and deleting records are also disabled in "Results".

Should I run code from a macro, on the query or try another event (I've tried many events though with no success)?

Thanks for the help, and sorry for the noob question!

1
Isn't this a syntax error? Else: should be Else ? (Sorry if I am wrong, my VB skills are minimal, but i thought : is reserved for goto statements.) - Stefan
VBA autocorrected Else to Else: so I don't think it inserted an error :) - BlackDog

1 Answers

0
votes

Continuous Forms behave differently than what you think. It cannot work with UnBound Controls. If the control Number is bound it will take effect on only the Record that has foucs. Using Form Current combined with Load should/might work, but again it will not be the best solution. Because it will be applied to all other records in the SubForm.

Example of what I mean is, if the form has three records. First Record has Type (a terrible field/control name) "Reclamation" then the "current" record's Number (again a very bad field/control name) will be hidden along with all the other record's Number, even if they have other Type's in their record.

I would suggest you to go with Single Form.