[access] field visible on condition
Renaissance
Posted messages
2
Status
Member
-
wardan Posted messages 6 Registration date Status Member Last intervention -
wardan Posted messages 6 Registration date Status Member Last intervention -
Hello, I am new to this forum and I am seeking help from Access specialists. I am creating a furniture management database (tables, forms) and so far, no problem. In a form, I have two fields: a "Category" field and a "Seat Height" field. I want the "Seat Height" field to appear when the "Category" field contains the value "Seat". I wrote the following code in the After Update property of the "Category" field:
If [Category] = "Seat" Then
[Seat Height].Visible = True
Else
[Seat Height].Visible = False
End If
This does not work because it applies to all records in the table and does not remain in memory on the specific record.
How can I do this? Thank you for your valuable help
If [Category] = "Seat" Then
[Seat Height].Visible = True
Else
[Seat Height].Visible = False
End If
This does not work because it applies to all records in the table and does not remain in memory on the specific record.
How can I do this? Thank you for your valuable help
Configuration: Windows XP Access 2003
26 answers
- 1
- 2
Next
```html
j'ai le même problème, j'ai mis mon code dans Current et je veux que si une date n'est pas saisie alors mon champ est activé, sinon non et ça ne marche pas :s
Private Sub Form_Current() If Not IsNull([dateValidPlanMinute]) Then [remarqueNonValid].Enabled = True Else [remarqueNonValid].Enabled = False End If End Sub```
Private Sub Form_Current() If Not IsNull(dateValidPlanMinute) Then [remarqueNonValid].Visible = True Else [remarqueNonValid].Visible = False End If End Sub
you also need to put this code in the BeforeUpdate event (Cancel As Integer) as HDU mentioned
Private Sub dateValidPlanMinute_BeforeUpdate(Cancel As Integer) If Not IsNull(dateValidPlanMinute) Then [remarqueNonValid].Visible = True Else [remarqueNonValid].Visible = False End If End Sub
Hello,
This should help you: https://grenier.self-access.com/?post/2007/09/05/Listes-deroulantes-liees
See you
--
When Jimmy says what’d I say, I love you baby
It’s like they say, the whole province singing in English
This should help you: https://grenier.self-access.com/?post/2007/09/05/Listes-deroulantes-liees
See you
--
When Jimmy says what’d I say, I love you baby
It’s like they say, the whole province singing in English
Hello,
I'm taking advantage of this discussion because I have a similar problem:
if the value of the field is "toto", I want a boxxxx to appear or disappear that surrounds or does not surround part of a text in my form
I used similar code:
me.boitexxx.Visible = False
If [Field] = "toto" Then
me.boitexxx.Visible = True
else
me.boitexxx.Visible = False
End If
To see the box xxx appear or disappear, I must focus on the field that contains "toto", otherwise nothing happens...
My form is in continuous mode, if I change the record without being focused on the field, I don't get the expected effect.
Do you have any idea?
I'm taking advantage of this discussion because I have a similar problem:
if the value of the field is "toto", I want a boxxxx to appear or disappear that surrounds or does not surround part of a text in my form
I used similar code:
me.boitexxx.Visible = False
If [Field] = "toto" Then
me.boitexxx.Visible = True
else
me.boitexxx.Visible = False
End If
To see the box xxx appear or disappear, I must focus on the field that contains "toto", otherwise nothing happens...
My form is in continuous mode, if I change the record without being focused on the field, I don't get the expected effect.
Do you have any idea?
I am not very experienced...
I did:
in properties, the event tab,
after updating [Event procedure] and there I copied the code.
Can you tell me what the current() event of the form is?
Thank you.
I did:
in properties, the event tab,
after updating [Event procedure] and there I copied the code.
Can you tell me what the current() event of the form is?
Thank you.
In the list at the top right, all I see is:
After update, beforeupdate, change, click ...etc
I don't see this so-called "current event"
Moreover, I'm already under the form object. That's where the code is copied.
Should it have been copied elsewhere before? How?
Can you give me a bit more explanations for a novice...
Thank you
After update, beforeupdate, change, click ...etc
I don't see this so-called "current event"
Moreover, I'm already under the form object. That's where the code is copied.
Should it have been copied elsewhere before? How?
Can you give me a bit more explanations for a novice...
Thank you
Under which version of Access?
But you *must* have current()
Look at a screenshot: https://www.cjoint.com/?lEq5IhTDlu
--
When Jimmy says what’d I say, I love you baby
It's like saying, the whole province is singing in English.
But you *must* have current()
Look at a screenshot: https://www.cjoint.com/?lEq5IhTDlu
--
When Jimmy says what’d I say, I love you baby
It's like saying, the whole province is singing in English.
Hi everyone, I'm new to the forum
I have a problem with combo boxes, actually I would like to display a list based on another list, more specifically:
when choosing an item from one combo, the items in the second combo should change. I tried using a query but it doesn't work. And this in the same form (Access 2003)
I have a problem with combo boxes, actually I would like to display a list based on another list, more specifically:
when choosing an item from one combo, the items in the second combo should change. I tried using a query but it doesn't work. And this in the same form (Access 2003)
Hello, three years later....
I'm brand new to Access but super motivated!
I'm working in Access for equipment management. The database has already been created, but not by me.
I would like to add this to the database: when I check a "checkbox" on a form, it displays text. If the box is not checked, it doesn't display.
Another condition: On my main form, I have all the texts that are displayed, so I can find my way around. When I check the corresponding box on this form, I want it to display on a report created specifically for that purpose.
I've already created my table, my form, and my report, but I'm a bit overwhelmed by the queries and relationships... I need a little help....
Thank you for your responses.
I'm brand new to Access but super motivated!
I'm working in Access for equipment management. The database has already been created, but not by me.
I would like to add this to the database: when I check a "checkbox" on a form, it displays text. If the box is not checked, it doesn't display.
Another condition: On my main form, I have all the texts that are displayed, so I can find my way around. When I check the corresponding box on this form, I want it to display on a report created specifically for that purpose.
I've already created my table, my form, and my report, but I'm a bit overwhelmed by the queries and relationships... I need a little help....
Thank you for your responses.
Hello,
In your form, in creation mode, right-click on the checkbox that should trigger the display or disappearance of the text, select "create event code," code generator if it asks you. Normally, Access will offer to assign code to the 'click' event (box at the top right) of the checkbox (top left).
That's what you want --> to do something when the user clicks on the checkbox.
You want to display or hide some text. Where is this text? In a text box? A label?
In any case, you know the name of the control that contains the text. It's called "texte1."
So, in the click event of your checkbox ("cocher1" for example), you put:
For your other question, I didn't quite get it! Apparently you have checkboxes on a form and you want these boxes to appear on a report?
If that's the case, do your boxes correspond to your fields in one (or several tables)?
I’m waiting for your answer to guide you.
See you soon
--
When Jimmy says what’d I say, I love you baby
It's as if the whole province is singing in English.
In your form, in creation mode, right-click on the checkbox that should trigger the display or disappearance of the text, select "create event code," code generator if it asks you. Normally, Access will offer to assign code to the 'click' event (box at the top right) of the checkbox (top left).
That's what you want --> to do something when the user clicks on the checkbox.
You want to display or hide some text. Where is this text? In a text box? A label?
In any case, you know the name of the control that contains the text. It's called "texte1."
So, in the click event of your checkbox ("cocher1" for example), you put:
if texte1=true then 'if the box is checked me!texte1.visible=true 'we display the text zone texte1 else me!texte1.visible=false end if
For your other question, I didn't quite get it! Apparently you have checkboxes on a form and you want these boxes to appear on a report?
If that's the case, do your boxes correspond to your fields in one (or several tables)?
I’m waiting for your answer to guide you.
See you soon
--
When Jimmy says what’d I say, I love you baby
It's as if the whole province is singing in English.
Hi and thanks for this initial information... I see things more clearly
The issue is that, here’s what I would ideally like to do:
I have a form that is part of a pre-built database.
On this form, I have checkboxes with titles for example:
chkbox 1: meals
chkbox 2: hotel
chkbox 3: travel
I want to choose in this form what I want to display but on a corresponding report and not on the form. The text described in the report is more complete than on the form, like "provide for 5 meals"
With the code you gave me, it makes it visible on the form. Moreover, it actually makes it invisible and it doesn’t reappear afterwards. I would like it to have the opposite effect as well.
Even better, I would like that if I check box 2, the meals are displayed at the top of the report and not in the middle.
Thank you for your help
The issue is that, here’s what I would ideally like to do:
I have a form that is part of a pre-built database.
On this form, I have checkboxes with titles for example:
chkbox 1: meals
chkbox 2: hotel
chkbox 3: travel
I want to choose in this form what I want to display but on a corresponding report and not on the form. The text described in the report is more complete than on the form, like "provide for 5 meals"
With the code you gave me, it makes it visible on the form. Moreover, it actually makes it invisible and it doesn’t reappear afterwards. I would like it to have the opposite effect as well.
Even better, I would like that if I check box 2, the meals are displayed at the top of the report and not in the middle.
Thank you for your help
Re,
In my opinion, there is already a design issue...
For the opposite effect as you mentioned, the code I gave you should work. Obviously on the form.
Let us know what tables you have and what the database is for, in short, what you want it to manage.
Catch you later
--
When Jimmy says what’d I say, I love you baby
It’s like saying, the whole province singing in English
In my opinion, there is already a design issue...
For the opposite effect as you mentioned, the code I gave you should work. Obviously on the form.
Let us know what tables you have and what the database is for, in short, what you want it to manage.
Catch you later
--
When Jimmy says what’d I say, I love you baby
It’s like saying, the whole province singing in English
uh... it would be a bit long to describe because I didn't design the database. There are 50 tables and just as many forms and queries, possibly...
Let me explain:
The database was created to manage equipment rental. Basically, it manages a client file, manages the stock of equipment, and issues quotes and invoices...
I want to make a quote. So I open a form where I enter my client, my products... and I generate the quote (document)
Everything works well, but in addition to that, I want to add those little checkboxes in my form that I can check or not. Then I press a button, and it generates the corresponding document with the text from checkbox 1 and 3 displayed because I checked box 1 and 3 and the text from checkbox 2 not displayed because I didn't check checkbox 2 for this specific quote.
Well, it may seem a bit complicated like that, but it would be very useful to me...
Thank you
Let me explain:
The database was created to manage equipment rental. Basically, it manages a client file, manages the stock of equipment, and issues quotes and invoices...
I want to make a quote. So I open a form where I enter my client, my products... and I generate the quote (document)
Everything works well, but in addition to that, I want to add those little checkboxes in my form that I can check or not. Then I press a button, and it generates the corresponding document with the text from checkbox 1 and 3 displayed because I checked box 1 and 3 and the text from checkbox 2 not displayed because I didn't check checkbox 2 for this specific quote.
Well, it may seem a bit complicated like that, but it would be very useful to me...
Thank you
What I’m proposing is that you send me your zipped database.
If you’re worried about your data (I’m not a crook lol), make a copy and empty the “sensitive” tables.
I'll have a better look "visually" because right now it’s blurry!
My email is in my profile.
However, I won’t be able to look at this until Monday afternoon, I’m heading off for the weekend.
See you!
--
When Jimmy says what’d I say, I love you baby
It’s like they say, the whole province singing in English.
If you’re worried about your data (I’m not a crook lol), make a copy and empty the “sensitive” tables.
I'll have a better look "visually" because right now it’s blurry!
My email is in my profile.
However, I won’t be able to look at this until Monday afternoon, I’m heading off for the weekend.
See you!
--
When Jimmy says what’d I say, I love you baby
It’s like they say, the whole province singing in English.
I sincerely appreciate your help, but I can't send you the database because it is part of software with access code. So if I send it to you, you won't be able to open it....
Let me know if I'm on the right track:
In the table of my quote form, I have "name, first name... (of the client); AN8, PT4... (which correspond to the product, price...) ....
I added several checkbox columns to this table that I named VCHEK1, VCHEK2, VCHEK3, VCHEK4
In my form, I added an "existing field" and I dragged from my table VCHEK1, VCHEK2...
Then I created a report, and it's in this report that the text corresponding to the VCHEK1 checkbox should appear if I checked it. And that's where I'm stuck.... Furthermore, I would like that if I check boxes 1 and 3, the corresponding text in the report appears one after the other, without a big gap in the middle where there would be text 2
So that's it, and thanks again.
Let me know if I'm on the right track:
In the table of my quote form, I have "name, first name... (of the client); AN8, PT4... (which correspond to the product, price...) ....
I added several checkbox columns to this table that I named VCHEK1, VCHEK2, VCHEK3, VCHEK4
In my form, I added an "existing field" and I dragged from my table VCHEK1, VCHEK2...
Then I created a report, and it's in this report that the text corresponding to the VCHEK1 checkbox should appear if I checked it. And that's where I'm stuck.... Furthermore, I would like that if I check boxes 1 and 3, the corresponding text in the report appears one after the other, without a big gap in the middle where there would be text 2
So that's it, and thanks again.
Hello,
At first glance, if I stick exactly to what you're telling me, you have a quote table with product codes in it?
If that's the case, it sounds like a convoluted setup.
But then again, you might not have time to redo a database from scratch.
In your state, like in your form, you can create code to show/hide objects (controls).
In design mode, right-click and then create the event code, the code generator.
You choose the open() event and there you put the appropriate code, like:
if vchek2=true then
me.texte3.visible=true
.....
else
me.texte3.visible=false
.....
end if
Of course, this needs to be adapted.
For the "big hole in the middle" as you say, I don't really see how you have just one quote table. The use of sub-reports was definitely indicated.
If not, but it’s honestly a hack, you can use the above code to position your objects.
So, if your texte3 is not visible, you need to "move up" your texte4, with its properties:
if vchek2=true then
me.texte3.visible=true
me.texte4.top=
....
But that’s a hack...
Give me the structure of your tables, there might be a simpler way.
See you soon
--
When Jimmy says what’d I say, I love you baby
It’s like saying, the whole province sings in English.
At first glance, if I stick exactly to what you're telling me, you have a quote table with product codes in it?
If that's the case, it sounds like a convoluted setup.
But then again, you might not have time to redo a database from scratch.
In your state, like in your form, you can create code to show/hide objects (controls).
In design mode, right-click and then create the event code, the code generator.
You choose the open() event and there you put the appropriate code, like:
if vchek2=true then
me.texte3.visible=true
.....
else
me.texte3.visible=false
.....
end if
Of course, this needs to be adapted.
For the "big hole in the middle" as you say, I don't really see how you have just one quote table. The use of sub-reports was definitely indicated.
If not, but it’s honestly a hack, you can use the above code to position your objects.
So, if your texte3 is not visible, you need to "move up" your texte4, with its properties:
if vchek2=true then
me.texte3.visible=true
me.texte4.top=
....
But that’s a hack...
Give me the structure of your tables, there might be a simpler way.
See you soon
--
When Jimmy says what’d I say, I love you baby
It’s like saying, the whole province sings in English.
Hi,
Sorry, but I'm at work and I'm off this evening, so I have quite a few things to wrap up.
Either you reduce your labels as much as possible and stack them on top of each other; they'll then be almost at the same height (when reduced, they'll be about 1 mm in height).
You set their 'autoextensible' property to yes, does it work (not tested)?
Or, you leave them as is, and in the code you used to make your labels visible/invisible, you adjust the properties to display them higher or lower in the state (ME.E2.Top=7.55 for example).
See you later
--
When Jimmy says what’d I say, I love you baby
It’s like saying, the whole province singing in English
Sorry, but I'm at work and I'm off this evening, so I have quite a few things to wrap up.
Either you reduce your labels as much as possible and stack them on top of each other; they'll then be almost at the same height (when reduced, they'll be about 1 mm in height).
You set their 'autoextensible' property to yes, does it work (not tested)?
Or, you leave them as is, and in the code you used to make your labels visible/invisible, you adjust the properties to display them higher or lower in the state (ME.E2.Top=7.55 for example).
See you later
--
When Jimmy says what’d I say, I love you baby
It’s like saying, the whole province singing in English
Thank you for taking the time to respond to me DHU, even during your vacation!!! Enjoy your vacation then!!!
As for your code in your second solution, I'm not quite sure where to insert it. My code is as follows:
If Forms!P!verso_pretstaion.Form!CB_repas = -1 Then
Date_repas.Visible = True
Else
Date_repas.Visible = False
End If
The problem is also that 7.55 is fine if only the previous line is inactive... but what if it were the 4 previous lines?
I need to be able to say:
if checkbox 1 is inactive then label 2 takes the place of label 1
and if checkbox 1 is active, checkbox 2 is inactive, checkbox 3 is inactive, checkbox 4 is active, label 4 takes the place of label 2...
But it's easier said than done...
As for your code in your second solution, I'm not quite sure where to insert it. My code is as follows:
If Forms!P!verso_pretstaion.Form!CB_repas = -1 Then
Date_repas.Visible = True
Else
Date_repas.Visible = False
End If
The problem is also that 7.55 is fine if only the previous line is inactive... but what if it were the 4 previous lines?
I need to be able to say:
if checkbox 1 is inactive then label 2 takes the place of label 1
and if checkbox 1 is active, checkbox 2 is inactive, checkbox 3 is inactive, checkbox 4 is active, label 4 takes the place of label 2...
But it's easier said than done...
Thank you,
Yes, we should test the possibilities, and it's not easy and it's not clean.
Have you tried the first solution? (minimize the labels as much as possible and set their 'autoextensible' property to yes)
See you later
--
When Jimmy says what’d I say, I love you baby
It's like someone would say, the whole province singing in English
Yes, we should test the possibilities, and it's not easy and it's not clean.
Have you tried the first solution? (minimize the labels as much as possible and set their 'autoextensible' property to yes)
See you later
--
When Jimmy says what’d I say, I love you baby
It's like someone would say, the whole province singing in English
Hi HDU, sorry for this absence... ah, vacations...
I tried your solution of sticking the labels together and making them auto-resizable...
Several things: we cannot make the labels auto-resizable but only the text boxes... which is problematic in my case...
On the other hand, I tried with text boxes but that doesn't solve the issue... I end up with 2 text boxes almost on top of each other if I validate both...
I then went a bit higher up in the forum and reread one of your posts that said this:
""So, if your text3 is not visible, you need to "raise" your text4, with its properties:
if vchek2=true then
me.text3.visible=true
me.text4.top= ""
I wanted to know where to put this property so I can try.
On the other hand, will the "top" raise the text up to the previous text? Are you sure it won't just raise it to the top of the page?
Finally, I also saw a message where you told me that the subreport was just right... I don't know anything about subreports. Is it difficult to get started?
Thanks once again...
I tried your solution of sticking the labels together and making them auto-resizable...
Several things: we cannot make the labels auto-resizable but only the text boxes... which is problematic in my case...
On the other hand, I tried with text boxes but that doesn't solve the issue... I end up with 2 text boxes almost on top of each other if I validate both...
I then went a bit higher up in the forum and reread one of your posts that said this:
""So, if your text3 is not visible, you need to "raise" your text4, with its properties:
if vchek2=true then
me.text3.visible=true
me.text4.top= ""
I wanted to know where to put this property so I can try.
On the other hand, will the "top" raise the text up to the previous text? Are you sure it won't just raise it to the top of the page?
Finally, I also saw a message where you told me that the subreport was just right... I don't know anything about subreports. Is it difficult to get started?
Thanks once again...
Hello,
I also have a problem trying to make a field visible conditionally.
The field remains visible regardless of the condition.
Here is my code, hoping someone can help me.
Private Sub Form_Current()
If EMPLOI = "Unemployed" Then
nivrequis.Visible = False
Else
nivrequis.Visible = True
End If
End Sub
Private Sub nivrequis_BeforeUpdate(Cancel As Integer)
If EMPLOI = "Unemployed" Then
nivrequis.Visible = False
Else
nivrequis.Visible = True
End If
End Sub
I also have a problem trying to make a field visible conditionally.
The field remains visible regardless of the condition.
Here is my code, hoping someone can help me.
Private Sub Form_Current()
If EMPLOI = "Unemployed" Then
nivrequis.Visible = False
Else
nivrequis.Visible = True
End If
End Sub
Private Sub nivrequis_BeforeUpdate(Cancel As Integer)
If EMPLOI = "Unemployed" Then
nivrequis.Visible = False
Else
nivrequis.Visible = True
End If
End Sub
[access] field visible on condition
Hello,
try this:
Private Sub Form_Current()
If [EMPLOYMENT]= "Unemployed" Then
me.nivrequis.Visible = False
Else
me.nivrequis.Visible = True
End If
End Sub
Private Sub nivrequis_BeforeUpdate(Cancel As Integer)
If [EMPLOYMENT] = "Unemployed" Then
me.nivrequis.Visible = False
Else
me.nivrequis.Visible = True
End If
End Sub
Hello,
try this:
Private Sub Form_Current()
If [EMPLOYMENT]= "Unemployed" Then
me.nivrequis.Visible = False
Else
me.nivrequis.Visible = True
End If
End Sub
Private Sub nivrequis_BeforeUpdate(Cancel As Integer)
If [EMPLOYMENT] = "Unemployed" Then
me.nivrequis.Visible = False
Else
me.nivrequis.Visible = True
End If
End Sub
When you are in VBA (where you have placed the code), select the form object from the list at the top left, choose the current event from the list at the top right. Copy the code...
--
When Jimmy says what’d I say, I love you baby
It’s like saying, the whole province is singing in English
--
When Jimmy says what’d I say, I love you baby
It’s like saying, the whole province is singing in English
Hello,
I have a similar problem but in Word.
I created a form and I would like the checkboxes to be interactive when someone fills it out.
Let me explain: in the question about the product material, there are options for Steel or Stainless Steel, and I want the person filling it out to be able to check only one box (either one or the other, but not both).
Thank you.
I have a similar problem but in Word.
I created a form and I would like the checkboxes to be interactive when someone fills it out.
Let me explain: in the question about the product material, there are options for Steel or Stainless Steel, and I want the person filling it out to be able to check only one box (either one or the other, but not both).
Thank you.
- 1
- 2
Next
Thank you very much