Results 1 to 7 of 7
  1. #1
    MunroeM is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    55

    Problem with save button bypassing required fields on form

    Hello,

    I have a form which you can sign in and out tags. I have pre populated the table with all the tag numbers we have (000 to 175) (Picture 1 bottom of page).

    When you sign out a Tag you are required to enter 5 fields minimum (Tag Number{Tag Num is a combo box of all the pre populated tag numbers}, Description, Location(board/Kit#), Date Out and Who Signed it out). This works fine most of the time.

    When you Sign in a Tag you select a tag number from a combo box that only shows signed out tags. In my VB code i run a "append query" to copy the record to a history table and then i set all fields except the tag number back to "" (at the bottom of the code below)

    Code:
    ' Save And Exit Button
    Private Sub SaveExit_Click()
        If Me.SignInOut.Value = 1 And Me.Combo120.ListIndex = -1 Then 'signout button and signout dropdown box
            MsgBox "Please Select a Deployed Tag Number"
            Me.Combo120.SetFocus
            Exit Sub
        ElseIf Me.SignInOut.Value = 2 And Me.Combo231.ListIndex = -1 Then 'SignIn button and signin dropdown box
            MsgBox "Please Select a Deployed Tag Number"
            Me.Combo231.SetFocus
            Exit Sub
        ElseIf Me.SignInOut.Value = 1 And IsNull(Description) Then 'SignOut button and No Description
            MsgBox "Please Enter What the Item is."
            Me.Description.SetFocus
            Exit Sub
        ElseIf Me.SignInOut.Value = 1 And IsNull(Location) Then 'SignOut button and No Location
            MsgBox "Please Enter the Tool Board/Kit Number the Item is held in."
            Me.Location.SetFocus
            Exit Sub
        ElseIf Me.SignInOut.Value = 1 And IsNull(DateBy) Then 'SignOut button and No Date
            MsgBox "Please Enter when the tag was Signed Out."
            Me.DateBy.SetFocus
            Exit Sub
        ElseIf Me.SignInOut.Value = 1 And IsNull(SignedBy) Then 'SignOut button and No Name
            MsgBox "Please Enter Who Signed the Tag Out."
            Me.SignedBy.SetFocus
            Exit Sub
        ElseIf Me.SignInOut.Value = 2 And IsNull(DateBy) Then 'SignIn Button and No Date
            MsgBox "Please Enter when the tag was Signed Out."
            Me.DateBy.SetFocus
            Exit Sub
        ElseIf Me.SignInOut.Value = 2 And IsNull(SignedBy) Then 'SignIn button and No Name
            MsgBox "Please Enter Who Signed the Tag Out."
            Me.SignedBy.SetFocus
            Exit Sub
        ElseIf Me.SignInOut.Value = 1 Then ' Sign Out
            Me.SignedOut.Value = "Yes"
            Me.DateBy = Me.DateOut
            Me.SignedOutBy = Me.SignedBy
            DoCmd.Close
        ElseIf Me.SignInOut.Value = 2 Then ' Sign in
            Me.DateIn = Me.DateBy
            Me.SignedInBy = Me.SignedBy
            DoCmd.RunCommand acCmdSaveRecord ' Saves record so Datein and SigninBy update on table
            DoCmd.SetWarnings False
            DoCmd.OpenQuery "AppendDepTagInQ" ' Copies record to history
            DoCmd.SetWarnings True
            ' Erases the Info in the Record but keeps the Tag Number after the record has been copied to TemmisTagHistoryT
            Me.SignedOut.Value = "no"
            Me.Combo120.Value = ""
            Me.TemmisNum.Value = ""
            Me.NSN.Value = ""
            Me.Description.Value = ""
            Me.SerialNum.Value = ""
            Me.Location.Value = ""
            Me.Notes.Value = ""
            Me.PartNum.Value = ""
            Me.DateBy.Value = ""
            Me.SignedBy.Value = ""
            Me.SignedOutBy.Value = ""
            Me.DateOut.Value = ""
            DoCmd.Close
        End If
        
        
    End Sub
    Now my issue is that for some reason after a tag has been signed out and then back in If you go to sign out that same tag again it bypasses Description, Location and Sing out by fields. So some one can select a tag enter the date and it will save with only that info.

    Click image for larger version. 

Name:	ReportFull.jpg 
Views:	16 
Size:	209.7 KB 
ID:	23331

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    it bypasses Description, Location and Sing out by fields.
    What is 'it'? Are you saying certain lines of code are not executing? Have you tried to step debug by setting a breakpoint? Maybe your code is not firing at all because you need a different event.

  3. #3
    MunroeM is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    55
    If the tag has never been signed out then my code works great. But after the tag has been signed out and then signed back in the next time you go to sign it out it does not work. I can select the tag number from the drop down list and then enter the date and it will save the record. even though the description, Location and signed out by fields are blank.

    In the photo above you can see tags 3, 10 and 11 are currently signed out and the rest are not signed out. When i sign tag 3 back in it will have all fields blank except for the tag # field that will still stay as 003.


    To give you an idea of how its should work normaly have a look at this picture.
    Click image for larger version. 

Name:	Form.jpg 
Views:	9 
Size:	131.4 KB 
ID:	23332
    So the user first selects sign out button.
    The Temmis tag out will unlock and they can select a tag that is not signed out currently from that list.
    Once a tag has been selected the rest of the fields unlock and you can entre data into them.
    If they click on the save and exit button right after selecting the tag and they did not enter any data then a msg box will pop up saying please enter the description and it will set focus on the description box.
    If then fill out description and they hit save with out filling out any other boxes it will pop up another msg box saying please enter the location and set focus to the location box.
    Same thig will happen for the date out box and signed out by box. If no data is entered a msg box will pop up saying it need to be filled out.
    Now here is where the trouble happens ... say for tag 3 its been signed out and back in once already so now its able to be signed back out. They select tag 3 and click save and exit with out filling out any of the other boxes it will skip the description and location checks and jump right to the date out check. It will say please enter a date and set focue to the date out box. Now if they hit save it will save the recored and skip the final check for Signed out by.
    Now i have a record for tag # 003 that only has the date out field entered which should not happen.

    I always have a hard time explaining how things should work so if you need me to i can upload the database if required

    Thanks for the help

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    ...If the tag has never been signed out then my code works great. But after the tag has been signed out and then signed back in the next time you go to sign it out it does not work...
    To be honest, trying to wade through this code is giving me a headache...my problem, not yours...but if you're talking about all of this happening in a single session, I'm guessing the problem lies with this kind of thing:

    IsNull(DateBy)

    Me.DateBy.Value = ""


    It works the first time around because an 'empty' field, such as DateBy, in Access, is generally Null. But later you assign a Zero-Length String ("") to 'reset' DateBy...and so the next time you test it, using

    IsNull(DateBy)

    the test fails...because a Zero-Length String and a Null are not the same thing! Instead of using

    IsNull(DateBy)

    you need to use code that checks for both a Zero-Length String and a Null. There are several ways to do this; everyone has a favorite, but this is one way:

    Nz(Me.DateBy,"") = ""

    You'll need to do this for all of you tests for 'empty' fields.

    Linq ;0)>

  5. #5
    MunroeM is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    55
    Perfect!

    I believe that is the issue im having. It makes perfect sence when you explained it above.

    I am going to try this and i will let you know if it works

    Thanks

  6. #6
    MunroeM is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    55
    Worked Like a Charm!

    Thanks for the help and sorry for the head ache from the code haha.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Good luck with your project!

    Linq ;0)>

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

Similar Threads

  1. Replies: 5
    Last Post: 04-19-2015, 12:42 AM
  2. form - save entered data only with save button
    By cbrxxrider in forum Forms
    Replies: 3
    Last Post: 10-20-2013, 12:39 PM
  3. Replies: 8
    Last Post: 09-19-2013, 11:19 AM
  4. Replies: 3
    Last Post: 10-08-2012, 08:40 AM
  5. Required Fields in a Form
    By Alaska1 in forum Access
    Replies: 3
    Last Post: 12-23-2010, 01:41 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