Results 1 to 13 of 13
  1. #1
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154

    If statement to remove the text box

    Dear all



    I am using the expression; some work some do not i have no idea why

    Can anyone tell me ?!


    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)



    If Me!Pass_A_30Nov = 0 Then
    Me!Pass_A_30Nov.Visible = False
    Else
    Me!Pass_A_30Nov.Visible = True
    End If


    If Me!Pass_B_28Nov = 0 Then
    Me!Pass_B_28Nov.Visible = False
    Else
    Me!Pass_B_28Nov.Visible = True
    End If

    If Me!Pass_B_29Nov = 0 Then
    Me!Pass_B_29Nov.Visible = False
    Else
    Me!Pass_B_29Nov.Visible = True
    End If

    If Me!Pass_B_30Nov = 0 Then
    Me!Pass_B_30Nov.Visible = False
    Else
    Me!Pass_B_30Nov.Visible = True
    End If

    If Me!Arr_Date = 0 Then
    Me!Arr_Date.Visible = False
    Else
    Me!Arr_Date.Visible = True
    End If


    If Me!Arr_FLT = 0 Then
    Me!Arr_FLT.Visible = False
    Else
    Me!Arr_FLT.Visible = True
    End If


    If Me!DropOff = 0 Then
    Me!DropOff.Visible = False
    Else
    Me!DropOff.Visible = True
    End If




    If Me!Dep_Date = 0 Then
    Me!Dep_Date.Visible = False
    Else
    Me!Dep_Date.Visible = True
    End If


    If Me!Dep_FLT = 0 Then
    Me!Dep_FLT.Visible = False
    Else
    Me!Dep_FLT.Visible = True
    End If


    If Me!PickUPHotel = 0 Then
    Me!PickUPHotel.Visible = False
    Else
    Me!PickUPHotel.Visible = True
    End If


    End Sub

    Click image for larger version. 

Name:	Vhr_1.JPG 
Views:	14 
Size:	16.2 KB 
ID:	30982


    Click image for larger version. 

Name:	Vhr_2.JPG 
Views:	13 
Size:	47.3 KB 
ID:	30983


    Click image for larger version. 

Name:	Vhr_3.JPG 
Views:	14 
Size:	40.0 KB 
ID:	30984

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    the visible property does not work for datasheets, only forms and reports

    What are you actually trying to do? just not show 0?

    If so, then use the format property for each control, no code required

    #;#;""

    Also, Arr_Date and Arr_FLT can never be 0 because they are not number types

    Finally, if you are going to stick with your code because I have misunderstood, you can simplify it to

    If Me.Pass_A_30Nov.Visible=Me.Pass_A_30Nov <>0

    note the use of dots (.) not bangs(!)

    And just noticed - if your example of 'not working' is Heritage, you don't appear to have any code for that

  3. #3
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Ajax

    Thanks and i tried , it seems not working if i changed to
    If Me.Pass_A_30Nov.Visible=Me.Pass_A_30Nov <>0

    Click image for larger version. 

Name:	Capture4.JPG 
Views:	11 
Size:	21.2 KB 
ID:	30993

    Also i want to hide the text box as the Unbound box can apply "can shrink"" function.

    As the list so long, i just want to show what have been booked, that is "1"

    So, the report can be slim

    Eric

  4. #4
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    aJAX

    Firstly, thanks for your help and i would like to share with you my work. sorry,i am fresh for Access

    The code above is work in some part and fail on the other.

    Hope you would enlighten me where went wrong

    Thanks
    Attached Files Attached Files

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Exactly what fails? I opened the report and code executes. Report looks fine.

    If you change code to the syntax described by Ajax, eliminate the If at the front, that is a typo error.

    Me.Pass_A_30Nov.Visible = Me.Pass_A_30Nov <> 0

    Regardless, the ! will work. However, when typing code the dot (.) will provoke intellisense popup help.


    What UNBOUND textbox?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    June 7

    So what went wrong when some work and some does not ?

    There is text box and unbound box - that save the "1" , and the text box is "description"

    i use can shrink to shrink the Unbound box, but the Text box has to hide the text box with the code


    Eric

  7. #7
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    June 7

    I tried to modify the code with your suggestion

    Me!CountryA.Visible = Me!CountryA <> 0

    But still not working... but after i close it an reopen, it works

    One more issue, how i can print the page header and record per ID in one page ?
    Thanks

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I don't see anything called 'description'. I don't see an unbound textbox, except for the date and page in the footer.

    If you don't want each record to start on a new page, set the Detail section ForceNewPage property to None.

    Data structure is bizarre. Why are there fields with date names, like Pass_A_28Nov?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    June 7

    Those field name strange but are what need to be ...

    I have tried and scroll down the report and find that still some work and some fail

    Click image for larger version. 

Name:	Capture10.JPG 
Views:	11 
Size:	27.3 KB 
ID:	30998

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Not in the file you posted. There are no 0's on the report.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    June

    As shown on screen cap. Dinner is a "0", it should be hidden.
    Country A is "0"should be hidden.

    The airport transfers shown nothing, as all is "0"

    Eric

  12. #12
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    June 7

    Did you amend my file and reload upload.

    the same coding that work on that file in Print preview mode

    What went wrong ?

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I downloaded your file and opened the report. No zeros. That includes Ref 13 shown in your image. I didn't change any code or data. What should I do to replicate the issue?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Remove Text and Keep Only Numbers
    By gameemaster in forum Queries
    Replies: 5
    Last Post: 04-17-2017, 09:15 PM
  2. Replies: 5
    Last Post: 02-20-2014, 10:17 AM
  3. Need to Remove Varying Middle Text
    By EZRider in forum Queries
    Replies: 4
    Last Post: 10-10-2012, 03:45 PM
  4. Replies: 3
    Last Post: 05-29-2012, 04:47 PM
  5. remove unwrap text
    By jamesz in forum Access
    Replies: 11
    Last Post: 03-14-2012, 11:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums