Results 1 to 11 of 11
  1. #1
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28

    Question Simple Hide and View Button Issue

    (I have a very limited coding ability)

    I have a form with a few text fields. My goal is the hide the "submit order" button until all fields are filled in(not null). The code I have just goes down the line and if you fill in the last box it makes the button visible.
    Code:
    Private Sub Form_Current() 
    
    
      If Nz(Me.AO, "") = "" Then
             Me.Command154.Visible = False 'Reconcile Button
         Else
            Me.Command154.Visible = True 'Reconcile Button
      
        End If
        
        If Nz(Me.Card_Holder, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
      
        End If
           
        If Nz(Me.Vendor, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
      
        End If
        
            If Nz(Me.Date_Requested, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
        
         If Nz(Me.Description, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
        
         If Nz(Me.Debit, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
        
         If Nz(Me.Requestor, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
        
         If Nz(Me.Status, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
        
         If Nz(Me.Catagory, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
        
         If Nz(Me.Item_Catagory, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
       
     End Sub


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    What is 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.

  3. #3
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28
    Quote Originally Posted by June7 View Post
    What is the issue?

    My code is not working.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    What does that mean? What happens - error message, wrong results, nothing?
    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.

  5. #5
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28
    I don't get any errors but the code is not functioning how I want it too. My goal is the hide the "submit order" button until all fields are filled in(not null). My code currently will hide it, but if you type something in the last field it makes the submit button visible. I want to ensure all fields are filled before that button become visible. My code can be tricked if a user just puts something in the last text field. Also, If you fill out the form then erase the text boxs it still shows the submit button. I would like the submit button to go away if any field becomes blank.

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    The population or lack of data for Card_Holder, Vendor, Date_Requested, Description, Debit, Requestor and Status will have no effect on the Visibility of the cmdClose Command Button, as your code is written! Regardless of how the Visibility is set by the first seven Controls, it will finally be set by the status of the final Control in the code, Catagory, as you've found out.

    Is you goal is to be able to submit the record if all Controls are filled, as the new record is entered, you need to do a validation in the Form_BeforeUpdate event, and when all Controls are populated, allow the submission.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28
    First, I would like to say thank you all for showing me so much patience. I am so glad there are people like you all that will help. Thank you very much!

    I would like to only allow the user to to submit the order form is all fields are filled out.

    you need to do a validation in the Form_BeforeUpdate event, and when all Controls are populated, allow the submission.
    That is the spot on! The only problem is ...I have no clue how to code that.

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Three questions:

    1. What if the user decides to dump the partial record, rather than complete it? You really need to allow this, if need be.
    2. What, exactly, is the code behind your cmdClose Command Button?
    3. Can you strip your file of confidential data, save it in either 2007 or 2003 file format, Zip it up and attach it to a post?


    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  9. #9
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28
    Quote Originally Posted by Missinglinq View Post
    Three questions:

    1. What if the user decides to dump the partial record, rather than complete it? You really need to allow this, if need be.
    2. What, exactly, is the code behind your cmdClose Command Button?
    3. Can you strip your file of confidential data, save it in either 2007 or 2003 file format, Zip it up and attach it to a post?


    Linq ;0)>
    1. I have a button that will delete and close the form.
    2. Its a simple macro that does a CloseWindow command. Nothing special
    3. I wish I could but I have lots of images loaded into the file which makes it massive. There is nothing secret about it. I have TeamViewer and would allow you to take a look that way. I will message you my phone number. If you would like to call me, I will be here all day banging my head on the table.

    4. I can post the code I have for the form I am working on. I don't know if it will help. I have tried to annotate everything.

    Code:
    Option Compare Database
    
    
    
    
    
    'I made this massive section of AfterUpdate commands to work with my Form_Current commands.
    'I thought if I made it rerun the form current each time it would check for logic.
    'I was wrong
    
    
    Private Sub Card_Holder_AfterUpdate()
    Form_Current
    End Sub
    Private Sub Vendor_AfterUpdate()
    Form_Current
    End Sub
    Private Sub Date_Requested_AfterUpdate()
    Form_Current
    End Sub
    Private Sub Description_AfterUpdate()
    Form_Current
    End Sub
    Private Sub Debit_AfterUpdate()
    Form_Current
    End Sub
    Private Sub Requestor_AfterUpdate()
    Form_Current
    End Sub
    Private Sub Status_AfterUpdate()
    Form_Current
    End Sub
    Private Sub Catagory_AfterUpdate()
    Form_Current
    End Sub
    Private Sub Item_Catagory_AfterUpdate()
    Form_Current
    End Sub
    
    
    
    
    'This small bit of code only allows users to reconcile an order if the "AO" has typed in his info. Plus alot more
    'I think this is a sloppy but I dont know what else to do.
    
    
     Private Sub Form_Current()
     
    
    
      If Nz(Me.AO, "") = "" Then
             Me.Command154.Visible = False 'Reconcile Button
         Else
            Me.Command154.Visible = True 'Reconcile Button
      
        End If
        
        If Nz(Me.Card_Holder, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
      
        End If
           
        If Nz(Me.Vendor, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
      
        End If
        
            If Nz(Me.Date_Requested, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
        
         If Nz(Me.Description, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
        
         If Nz(Me.Debit, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
        
         If Nz(Me.Requestor, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
        
         If Nz(Me.Status, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
        
         If Nz(Me.Catagory, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
        
         If Nz(Me.Item_Catagory, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
            
      
        End If
       
     End Sub
     
     
    ' This is the Reconcile Order button
     
    Private Sub Command154_Click()
        Label143.Visible = True
        Label140.Visible = True
        Label141.Visible = True
        Label142.Visible = True
        Labelpaid.Visible = True
        Reconciled_Date.Visible = True
        Basic_Amount.Visible = True
        Paidcheckbox.Visible = True
        Command253.Visible = True
    
    
    'Reconciled.Visible = True    'I have these out of the mix ATM
    'Label139.Visible = True      'I have these out of the mix ATM
    'Catagory.Visible = True      'I have these out of the mix ATM
    
    
    End Sub
    
    
    
    
    'This code makes sure that the user thinks before he clicks. If they click the paid box it will move the order to reconsiled.
    Private Sub Paidcheckbox_Click()
    If MsgBox("Are you sure you matched 100% of your current order on US Bank? Once you click this it will move this transaction to the Reconciled section", vbQuestion + vbYesNo) = vbYes Then
        Paidcheckbox.Value = True
        Else
            Paidcheckbox.Value = False
        End If
    End Sub

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Do you know that Access has a 2GB size limit? Embedding lots of large files will use this up fast.

    Code options:

    1. Use Exit Sub with each If Then
    Me.Command154.Visible = False 'Reconcile Button
    Exit Sub

    2. One very long expression with OR operators
    If Nz(Me.Card_Holder, "") = "" OR Nz(Me.Vendor, "") = "" OR ... Then
    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
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28
    Woot! It works perfect! Thank you so much for all the help!

    This is what I used and its perfect

    Code:
     Private Sub Form_Current() 
      If Nz(Me.AO, "") = "" Then
             Me.Command154.Visible = False 'Reconcile Button
         Else
            Me.Command154.Visible = True 'Reconcile Button
      End If
        
       If Nz(Me.Date_Requested, "") = "" Or Nz(Me.Vendor, "") = "" Or Nz(Me.Description, "") = "" Or Nz(Me.Debit, "") = "" Or Nz(Me.Requestor, "") = "" Or Nz(Me.Status, "") = "" Or Nz(Me.Catagory, "") = "" Or Nz(Me.Item_Catagory, "") = "" Then
             Me.cmdClose.Visible = False 'Submit Button
         Else
            Me.cmdClose.Visible = True 'Submit Button
      
        End If
    
    
        
    End Sub

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

Similar Threads

  1. Replies: 1
    Last Post: 09-27-2013, 12:49 PM
  2. Replies: 1
    Last Post: 07-21-2013, 10:13 PM
  3. Simple Joins issue
    By Davetartblog in forum Access
    Replies: 3
    Last Post: 09-21-2011, 07:43 PM
  4. Hide records from Form View
    By Douglasrac in forum Forms
    Replies: 9
    Last Post: 05-13-2011, 11:55 AM
  5. Simple issue?
    By Patience in forum Access
    Replies: 8
    Last Post: 05-29-2010, 07:02 AM

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