I've got a database which is based on several tables: one of them is called "Natural person" and another is called "Legal person". The tables store information about clients. I've also got a query which is supposed to join data from those tables and it gives something like that:
Now you can see that some fields here are empty - for example Company_name in first record.
I've got a form which refers to this query and inside it there is a combo box and some text boxes. Combo box is used to choose a Client_ID, and the text boxes are used to display information about client (Name, Surname, Company_name) from records. I want to be able to hide unnecessary text boxes when the fields are empty - for example: when the Company_name is empty then I want to hide a text box which is related to this field an so on.
I try to do this with code below (which is placed in Form_Current):
The code above works but there's a glitch and I can't find out what is creating it. Example: When I open a form - everything is visible like it should be (Name, Surname - visible, Company_name - not visible), when I change combo box value to 2 - everything is good (Company_name - visible, Name, Surname - not visible), but when I change combo box value from 2 to 1 or from 5 to 1 - then the Company_name text box isn't hiding and I can see an empty text box, while other text boxes are still invisible (but they should be visible, while Company_name text box shouldn't).
Please help me find a way to get rid of this problem - I am a beginner in Access, an I don't know what to do.
PS: Sorry for my English.
Code:
Client_ID Name Surname Company_name
1 Jeff Smith
2 TechCorp
3 Kate White
4 John Ritchie
5 Flower Shop
I've got a form which refers to this query and inside it there is a combo box and some text boxes. Combo box is used to choose a Client_ID, and the text boxes are used to display information about client (Name, Surname, Company_name) from records. I want to be able to hide unnecessary text boxes when the fields are empty - for example: when the Company_name is empty then I want to hide a text box which is related to this field an so on.
I try to do this with code below (which is placed in Form_Current):
Code:
If IsNull(Company_name.Value) Then
Me.Company_name.Visible = False
Me.Name.Visible = True
Me.Surname.Visible = True
Else
Me.Company_name.Visible = True
Me.Name.Visible = False
Me.Surname.Visible = False
End If
Please help me find a way to get rid of this problem - I am a beginner in Access, an I don't know what to do.
PS: Sorry for my English.