Results 1 to 13 of 13
  1. #1
    Stephanie53 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    246

    Command continues to popup message box..

    I have one command button that before you can execute the process it must have shipping information completed and then it will go on to the next step. But the message box still pops up even after the shipping info has been put in. please tell me where I went wrong in this code:



    Code:
    Private Sub cmdPeachtree_DblClick(Cancel As Integer)
       If Not ValidateShipping() Then
          MsgBoxOKOnly PleaseValidateShippingAddress
       Else
          Me![Status ID] = Peachtree_CustomerOrder
           If IsNull(Me![Shipper ID]) = True Then
             If IsNull(Me![Ship Name]) Then
                Me![Ship Name] = Ship_Name
                If IsNull(Me![Ship Address]) Then
                   Me![Ship Address] = Ship_Address
                   If IsNull(Me![Ship City]) Then
                      Me![Ship City] = Ship_City
                      If IsNull(Me![Ship State/Province]) Then
                         Me![Ship State/Province] = Ship_State_Province
                         If IsNull(Me![Ship ZIP/Postal Code]) Then
                            Me![Ship ZIP/Postal Code] = Ship_ZIP_Postal_Code
                            If IsNull(Me![Ship Country/Region]) Then
                               Me![Ship Country/Region] = Ship_Country_Region
                            End If
                            eh.TryToSaveRecord
                            SetFormState
                         End If
                      End If
                   End If
                End If
             End If
          End If
       End If
    End Sub
    Did i miss an "Else"? and if so if the shipping info is already in there it should just change the status per that command button.

    TIA

    Stephanie
    Last edited by RuralGuy; 05-30-2013 at 09:43 AM. Reason: Added indenting

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    How about showing us the ValidateShipping() code as well.

  3. #3
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742

    Question about the Purpose of the Code

    Ummm. Not sure what the idea behind this is. It looks to me like you need those Ifs to be serial, rather than nested. Something like this:
    Code:
             If IsNull(Me![Ship Name]) Then
               Me![Ship Name] = Ship_Name
             End if  
             If IsNull(Me![Ship Address]) Then
               Me![Ship Address] = Ship_Address
             End If
             If IsNull(Me![Ship City]) Then
               Me![Ship City] = Ship_City
             End If
    I'm not even sure that that is right, because if you change the address, you should certainly be changing the city/state/zip, or you might be sending to the right address in the wrong city! If I'm way off, could you please explain in English what that section of code is attempting to do?

  4. #4
    Stephanie53 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    246

    Vlaidation Code

    Here is the Validation Code

    Code:
    Function ValidateShipping() As Boolean
        If IsNull(Me![Shipper ID]) Then Exit Function
        If Nz(Me![Ship Name]) = "" Then Exit Function
        If Nz(Me![Ship Address]) = "" Then Exit Function
        If Nz(Me![Ship City]) = "" Then Exit Function
        If Nz(Me![Ship State/Province]) = "" Then Exit Function
        If Nz(Me![Ship ZIP/Postal Code]) = "" Then Exit Function
        
        ValidateShipping = True
    End Function

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I believe the ValidateShipping() function is always returning False. A better way to check for no entry is:
    If Len([YourControl] & "") = 0 Then
    Don't use the bang (!) here. Use the dot (.) instead. You want to point to the Control and Me. will bring up the selection of possible entries (intellisense). A bang will point to a field in the RecordSource of the same name rather than the control.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The suggestion I gave you covers ZLS (ZeroLengthStrings) as well as Nulls.

  7. #7
    Stephanie53 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    246
    ok i am confused as heck here...lol

    in post #3 you posted a code
    in post #5 you said something along the lines of validate shipping coming back as false always (so shouldnt i change that to true?)
    in post #6 you post about ZLS....hmmmm where the heck is that *tilting head to side scratching it in wonder*

    sorry but i feel like an idiot lol

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Post #3 was another responder. Try this function and see if the results are better:
    Code:
    Function ValidateShipping() As Boolean
       If Len(Me.[Shipper ID] & "") = 0 Then Exit Function
       If Len(Me.[Ship Name] & "") = 0 Then Exit Function
       If Len(Me.[Ship Address] & "") = 0 Then Exit Function
       If Len(Me.[Ship City] & "") = 0 Then Exit Function
       If Len(Me.[Ship State/Province] & "") = 0 Then Exit Function
       If Len(Me.[Ship ZIP/Postal Code] & "") = 0 Then Exit Function
       ValidateShipping = True
    End Function

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    BTW, I have not tried to figure out what your nested IF's will do yet. One problem at a time for me.

  10. #10
    Stephanie53 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    246
    yeaaa!! that worked!! Thank you!! :-)

    i am marking this solved!

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Great! Glad you got it working.

  12. #12
    Stephanie53 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    246
    those ifs are for a button to be sure that the department clicks on it they do have to fill it out...do i have too many here?

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If it is working the way you want then leave it alone. I'm just not that used to using that many nested IF's. I suspect serial IF's would work as well and would be easier to follow. Most developers try and write code that even THEY could maintain years later.
    Where EXACTLY is this getting its value: Me![Ship Name] = Ship_Name

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

Similar Threads

  1. Replies: 4
    Last Post: 01-20-2013, 06:34 PM
  2. Replies: 3
    Last Post: 07-04-2011, 02:44 AM
  3. Message popup based on USERNAME
    By jpkeller55 in forum Access
    Replies: 3
    Last Post: 12-19-2010, 09:51 PM
  4. Issues with Continues form
    By ducecoop in forum Access
    Replies: 3
    Last Post: 11-11-2010, 01:18 PM
  5. Customize Message Box On Command
    By jpkeller55 in forum Access
    Replies: 3
    Last Post: 09-08-2010, 09:18 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