When checkbox checked it shows textbox (1 Viewer)

Wizz_kid

Registered User.
Local time
Today, 01:35
Joined
Oct 16, 2019
Messages
15
Hello,

I have a form where i Check the checkbox there will be a textbox. As seen as in the attachment only one of the three checkboxes need to be checked to see the text. Only when I open a new record, the checkboxes are empty but the textbox will be shown (As seen in second attachment). When I check and uncheck the textbox, the textbox will be gone, but also gone in other records (As seen in the last attachment). How can I fix this?

I use the on click event:
Private Sub Check3_Click()
If Me.Check3.Value = True Then
Me.Text1.Visible = True
ElseIf Me.Check4.Value = True Then
Me.Text1.Visible = True
ElseIf Me.Check5.Value = True Then
Me.Text1.Visible = True
Else
Me.Text1.Visible = False
End If
End Sub

Private Sub Check4_Click()
If Me.Check3.Value = True Then
Me.Text1.Visible = True
ElseIf Me.Check4.Value = True Then
Me.Text1.Visible = True
ElseIf Me.Check5.Value = True Then
Me.Text1.Visible = True
Else
Me.Text1.Visible = False
End If
End Sub

Private Sub Check5_Click()
If Me.Check3.Value = True Then
Me.Text1.Visible = True
ElseIf Me.Check4.Value = True Then
Me.Text1.Visible = True
ElseIf Me.Check5.Value = True Then
Me.Text1.Visible = True
Else
Me.Text1.Visible = False
End If
End Sub
 

Attachments

  • Knipsel 1.PNG
    Knipsel 1.PNG
    2.5 KB · Views: 93
  • knipsel2.PNG
    knipsel2.PNG
    650 bytes · Views: 95
  • knipsel 3.PNG
    knipsel 3.PNG
    688 bytes · Views: 93

Minty

AWF VIP
Local time
Today, 00:35
Joined
Jul 26, 2013
Messages
10,368
You would need to use the on current event as well that fires when you move between records.

Something like

Me.Text1.visible = False

Also your code is overly complicated, I'm pretty sure this will work for any true value?

Me.Text1.visible = (Me.check1 or Me.check2 or Me.check3)
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:35
Joined
Oct 29, 2018
Messages
21,454
Hi. If you're using a continuous form and an unbound checkbox, you're going to have a hard time doing this.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:35
Joined
May 7, 2009
Messages
19,229
add this function inside your Form's code.
Code:
Public fnShowTextbox(Optional bolChecked As Boolean = False)
If bolChecked Then
	Me.Text1.Visible = (Me.Check3 Or Me.Check4 Or Me.Check5)
Else
	Me.Text1.Visible = (Me.NewRecord = True)
End If
End Function

For check3, Check4, Check5 remove your Click Code.
instead type this on their OnClick Event:
Code:
=fnShowTextbox(True)

add code also to the Form's Current Event.
Code:
Private Sub Form_Current()
	Call fnShowTexbox()
End Sub
 

Wizz_kid

Registered User.
Local time
Today, 01:35
Joined
Oct 16, 2019
Messages
15
You would need to use the on current event as well that fires when you move between records.

Something like

Me.Text1.visible = False

Also your code is overly complicated, I'm pretty sure this will work for any true value?

Me.Text1.visible = (Me.check1 or Me.check2 or Me.check3)

Thanks for your help. The code is now working. With the last line added. When i remove the older one's it isn't working. Is it possible to make the code easy?

Private Sub Check3_Click()
If Me.Check3.Value = True Then
Me.Text1.Visible = True
ElseIf Me.Check4.Value = True Then
Me.Text1.Visible = True
ElseIf Me.Check5.Value = True Then
Me.Text1.Visible = True
Else
Me.Text1.Visible = False
End If
End Sub

Private Sub Check4_Click()
If Me.Check3.Value = True Then
Me.Text1.Visible = True
ElseIf Me.Check4.Value = True Then
Me.Text1.Visible = True
ElseIf Me.Check5.Value = True Then
Me.Text1.Visible = True
Else
Me.Text1.Visible = False
End If
End Sub

Private Sub Check5_Click()
If Me.Check3.Value = True Then
Me.Text1.Visible = True
ElseIf Me.Check4.Value = True Then
Me.Text1.Visible = True
ElseIf Me.Check5.Value = True Then
Me.Text1.Visible = True
Else
Me.Text1.Visible = False
End If
End Sub

Private Sub Form_Current()
Me.Text1.Visible = (Me.Check3 Or Me.Check4 Or Me.Check5)
End Sub
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:35
Joined
Feb 19, 2002
Messages
43,233
The line of code in the current event does what the multiple lines of code in the other the other procedures does. Although you would need to make it a goggle. You could do that by first setting visible to false.

Me.text1.Visible = False
Me.Text1.Visible = (Me.Check3 Or Me.Check4 Or Me.Check5)


Since checking any one of the boxes activates the textbox, the process is overly complicated. Rather than using three independent checkboxes, all you need is a single option group.
 

Wizz_kid

Registered User.
Local time
Today, 01:35
Joined
Oct 16, 2019
Messages
15
Hey Guys,

The checkbox problem is solved. Now I have another question.
In pic 1 i can choose for the option verwerking: "wissen" (see pic2)
If this one is chosen then another dropdown box is coming where i can choose an reason. When I choose a other verwerking like "beschikbaar stellen" (see pic) then the other dropdown box will not shown. When I save a form with "wissen" and then make a new form with another option and then go back to the other form this extra dropdown will not show anymore (pic3). Does anyone know which code I can try for this?

I already tried:
Me.Reden_wissing.Visible = Me.Verwerking = "wissen"
But this give me errors.
 

Attachments

  • Pic.png
    Pic.png
    2.7 KB · Views: 94
  • Pic2.png
    Pic2.png
    7.2 KB · Views: 93
  • Pic3.png
    Pic3.png
    11.9 KB · Views: 101

Wizz_kid

Registered User.
Local time
Today, 01:35
Joined
Oct 16, 2019
Messages
15
Can you post a demo version of your db, so we can try it out?

Enclosed you will find the version. It opens the corresponding Form immediately and under "opmerkingen" I wrote the problem.
 

Attachments

  • Demo_DB.accdb
    1 MB · Views: 88

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:35
Joined
Oct 29, 2018
Messages
21,454
Enclosed you will find the version. It opens the corresponding Form immediately and under "opmerkingen" I wrote the problem.
Okay, thanks. I hope I understood what you meant. Check out the attached and let us know if this is what you wanted.
 

Attachments

  • Demo_DB.accdb
    1,012 KB · Views: 91

Wizz_kid

Registered User.
Local time
Today, 01:35
Joined
Oct 16, 2019
Messages
15
Okay, thanks. I hope I understood what you meant. Check out the attached and let us know if this is what you wanted.

Yes it is what I meant.
when the user chooses "Wissen" he can fill in the 2 other columns. (PIC: Wissen)
When the user chooses "Rectificatie" he can fill in the last column. (PIC: Rectificatie)

When I use the next form button underneath it is working fine, and the columns won't disappear if it is "Wissen" or "Rectificatie".

But when I press "Verwerking toevoegen i get an error. (PIC: When press verwerking toevoegen).

Can you maybe see why I get this error.
 

Attachments

  • Rectificeren.PNG
    Rectificeren.PNG
    7.6 KB · Views: 91
  • Wissen.PNG
    Wissen.PNG
    10.4 KB · Views: 77
  • When press verwerking toevoegen.PNG
    When press verwerking toevoegen.PNG
    13.3 KB · Views: 87

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:35
Joined
Oct 29, 2018
Messages
21,454
Yes it is what I meant.
when the user chooses "Wissen" he can fill in the 2 other columns. (PIC: Wissen)
When the user chooses "Rectificatie" he can fill in the last column. (PIC: Rectificatie)

When I use the next form button underneath it is working fine, and the columns won't disappear if it is "Wissen" or "Rectificatie".

But when I press "Verwerking toevoegen i get an error. (PIC: When press verwerking toevoegen).

Can you maybe see why I get this error.
Sorry, try this one then.
 

Attachments

  • Demo_DB.accdb
    1 MB · Views: 88

Wizz_kid

Registered User.
Local time
Today, 01:35
Joined
Oct 16, 2019
Messages
15
I have another question.
I have a form where I can choose the name from the user with a combo box.
This name is in the table employees. Does any one know how to automatically fill the telephone number and e-mail (These are text boxes). This information is also in the table employees.
 

Attachments

  • Pic.png
    Pic.png
    4.7 KB · Views: 90

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:35
Joined
Oct 29, 2018
Messages
21,454
Hi. Yes. You can include this information in the combobox as additional columns and then refer to them in unbound textboxes using the Column() property.
 

Wizz_kid

Registered User.
Local time
Today, 01:35
Joined
Oct 16, 2019
Messages
15
I'm building another form.
When the "Impact risico" is "Groot" or "Zeer groot" and "beveiligingsmaatregelen" is unchecked it needs to show the line "voorafgaande raadpleging AP".
When the "Impact risico" is "Groot" or "Zeer groot" and "beveiligingsmaatregelen" is checked it doesn't needs to show the line "voorafgaande raadpleging AP."
When the "Impact risico" is "zeer klein" or "Klein" or "neutraal" and "beveiligingsmaatregelen" is unchecked it doesn't needs to show the line "voorafgaande raadpleging AP"

I almost got it, when I choose "groot", it shows "voorafgaande raadpleging AP". But when I check beveiligingsmaatregelen and unchecked it then it will not show again. Also when adding a new form it need to show only the checkbox "beveiligingsmaatregelen" If i choose "zeer groot" and go to another page and come back the line "voorafgaande raadpleging AP" is disappeared. I hope you guys know how to make it workable.
 

Attachments

  • Database2.accdb
    992 KB · Views: 103

Users who are viewing this thread

Top Bottom