Show a specific field

saharalayer

New member
Local time
Today, 18:57
Joined
Dec 13, 2024
Messages
4
Hello everyone
I have a question about showing a data entry field.

Code: I made it and it works

Code:
Private Sub Combo6_AfterUpdate()
    If Me.Combo6.Value = True Then
       Me.Text4.Visible = True
    Else
       Me.Text4.Visible = False
    End If
End Sub

In the menu there are two options (Yes / No)

I want to show the input field when the person chooses (No)


Thanks in advance
 
yes/no, true/false, -1/0 are all the same Boolean values. So providing your combo is returning on of those values then code would be

Text4.visible=combo6=no (or false or 0)

If your combo is returning a text value then the code would be

Text4.visible=combo6=“no”
 
yes/no, true/false, -1/0 are all the same Boolean values. So providing your combo is returning on of those values then code would be

Text4.visible=combo6=no (or false or 0)

If your combo is returning a text value then the code would be

Text4.visible=combo6=“no”
Thanks for your quick response

My question is: When I choose Yes, the information entry box does not appear
When you choose no. The data box appears
 
I specialize in designing and programming websites, especially online stores.
Yet you are struggling with logic to hide/show a control?
Might want to start giving your controls some meaningful names? Combo6 and Text4 are not going to mean much in a few days time. :(
I hope you do not use such generic names when you create websites?

My question is: When I choose Yes, the information entry box does not appear
When you choose no. The data box appears
That is not what your code that you show does?

Code:
Me.Text4.Visible = Me.Combo6
Reverse that logic with NOT.

BTW Access Macros are very different to Excel macros. This would be a VBA question.
 
Last edited:
If data state affects the presentation of your user interface, you will need to calculate this presentation in two cases, 1) when user changes said data, and 2) when you arrive at a new record. This being the case, it is common practice to perform this presentation logic in a separate method, and then call this method as appropriate. Consider code like...
Code:
Private Sub Combo6_AfterUpdate()
    ResetUI
End Sub

Private Sub Form_Current()
    ResetUI
End Sub

Private Sub ResetUI()
    Me.Text4.Visible = Not Me.Combo6
End Sub
This ensures that the correct presentation of your UI can be asserted by a more diverse set of processes.
 
Hello everyone... Thank you for your feedback. I have restored my memory, haha, and fixed the errors.



The program is aimed at Arabic-speaking users, so the errors were due to language interference the client wants it in Arabic.



Code:
Private Sub Combo6_AfterUpdate()

    On Error GoTo ErrorHandler

    

    ' التحقق من أن Combo6 ليس فارغاً

    If IsNull(Me.Combo6.Value) Or Me.Combo6.Value = "" Then

        MsgBox "الرجاء اختيار قيمة من Combo6"

        Exit Sub

    End If

    

    ' التحقق من القيم وأظهر أو أخفي مربع النص بناءً على ذلك

    If Me.Combo6.Value = "Fammle" Then

        Me.Text4.Visible = True

    ElseIf Me.Combo6.Value = "Man" Then

        Me.Text4.Visible = False

    Else

        MsgBox "قيمة غير معروفة. الرجاء اختيار Man أو Fammle."

        Exit Sub

    End If



    Exit Sub

    

ErrorHandler:

    MsgBox "حدث خطأ: " & Err.Description

End Sub
 
you can simplify your code:
Code:
Private Sub Combo6_AfterUpdate()

    On Error GoTo ErrorHandler

    ' التحقق من أن Combo6 ليس فارغاً

    If IsNull(Me.Combo6.Value) Or Me.Combo6.Value = "" Then

        MsgBox "الرجاء اختيار قيمة من Combo6"

    Else
    If Me.Combo6<>"Fammle" And Me.Combo6 <> "Man" Then
            MsgBox "قيمة غير معروفة. الرجاء اختيار Man أو Fammle."
    Else
        Me.Text4.Visible = (Me.Combo6 = "Fammle")
    End If
    End If

    Exit Sub

ErrorHandler:

    MsgBox "حدث خطأ: " & Err.Description

End Sub
 

Users who are viewing this thread

Back
Top Bottom