Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 37
  1. #16
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,531
    Wow, I keep deleting the extra code tags and the forum puts them back in, splitting the code into 2 blocks. Ignore that, should all be together.

    Edit: Code format fixed by Matrix.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  2. #17
    jenkag875 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    25
    I put this code in and the forms displays, no error message of any sort at all. I put in a bogus number again as well as a valid #.

    Private Sub ApplID_AfterUpdate()
    If DCount("[ApplID]", "tblDQPersonGrowthAttainHS", "[ApplID]= '" & Me.ApplID & "'") > 0 Then
    If DCount("[ApplID]", "tblDQPersonGrowthAttainHS", "[ApplID]= '" & Me.ApplID & "'") <> 0 Then
    MsgBox "That Application ID already has a High School Growth Attainment tied to it, enter a different application ID."
    Else
    DoCmd.OpenForm FormName:="frmAddDQReviewer2PersonGrowthAttainHS"
    End If
    Else
    MsgBox "The Application ID entered is not in the database, enter a different Application ID."
    End If
    End Sub

  3. #18
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,531
    The first test should be against whatever table holds the list of valid ID's. What is the data type of ApplID?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #19
    jenkag875 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    25
    ApplID is text. Table tblDQPersonGrowthAttainHS is linked to one of the main tables tblDQPerson which also contains a field ApplID which is also text. That is the primary key in all of my tables when I'm joining them. There are several tables overall and some allow more than one entry per ApplID, but this tblDQPersonGrowthAttainHS only allows one.

  5. #20
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,531
    If I understand what you're trying to do, the first DCount() should be against tblDQPerson. At that point, you're trying to be sure it's a valid ID, right? Then you check if it's already in the growth table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #21
    jenkag875 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    25
    Yes. I do have the common field (ApplID) in both though, so I figured I could check for it directly in the Growth Attainment table and when I change it to look at tblDQPerson for the first If statement, the results are the same.

  7. #22
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,531
    Can you attach a db with just those tables and this form, to make it smaller?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #23
    jenkag875 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    25
    I'm attaching as a zipped file as it said it was too large. Not sure if that will allow you to see it but I'll try that.
    Attached Files Attached Files

  9. #24
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,531
    I don't see the code that isn't working. This worked in the immediate window:

    ?DCount("[ApplID]", "tblDQPerson", "[ApplID]= '1155608309'")
    1
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #25
    jenkag875 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    25
    I copied from an old form, so that was my mistake.

    This should be on: frmUpdateDQPersoGrowthAttainHS

    Private Sub ApplID_AfterUpdate()
    If DCount("[ApplID]", "tblDQPersonGrowthAttainHS", "[ApplID]= '" & Me.ApplID & "'") > 0 Then
    If DCount("[ApplID]", "tblDQPersonGrowthAttainHS", "[ApplID]= '" & Me.ApplID & "'") <> 0 Then
    MsgBox "That Application ID already has a High School Growth Attainment tied to it, enter a different application ID."
    Else
    DoCmd.OpenForm FormName:="frmAddDQReviewer2PersonGrowthAttainHS"
    End If
    Else
    MsgBox "The Application ID entered is not in the database, enter a different Application ID."
    End If
    End Sub

  11. #26
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,531
    I'm not sure how you expect that textbox to work in conjunction with the criteria in the source query, so I added a textbox to test with. This performed as expected:

    Code:
    Private Sub Text47_AfterUpdate()
        If DCount("[ApplID]", "tblDQPerson", "[ApplID]= '" & Me.Text47 & "'") > 0 Then
            If DCount("[ApplID]", "tblDQPersonGrowthAttainHS", "[ApplID]= '" & Me.Text47 & "'") <> 0 Then
                MsgBox "That Application ID already has a High School Growth Attainment tied to it, enter a different application ID."
            Else
                MsgBox "opening form"
                'DoCmd.OpenForm FormName:="frmAddDQReviewer2PersonGrowthAttainHS"
            End If
        Else
            MsgBox "The Application ID entered is not in the database, enter a different Application ID."
        End If
    End Sub
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #27
    jenkag875 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    25
    I inserted a text box on the form and copied your code in exactly as text box was also named Text47 and I didn't get any message to display for a valid ID entered. It's in the form header.

  13. #28
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,531
    Are you hitting enter or tab after entering a value? Is any code running the db? If I enter 1155609007 I get the open form message box. With 1234 I get the ID not in the database message. With 1155614635 I get the duplicate message.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #29
    jenkag875 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    25
    I have tried enter or clicking directly enter an application ID into the parameter box. I entered 111, no message, just the form was there. When I entered a valid ID, same, form just opened with entry displayed. There is just code on each form but nothing on it as a whole

  15. #30
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,531
    I'm talking about entering a value in the new textbox, not the parameter prompt that comes up and says "Enter an application # to update the growth attainment(s) section:". That prompt is the query criteria, and filters the form to the input number.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 16
    Last Post: 02-01-2016, 05:42 PM
  2. Replies: 4
    Last Post: 10-03-2014, 06:36 AM
  3. Combo Box Wizard does not have option form option
    By CementCarver in forum Forms
    Replies: 5
    Last Post: 02-28-2013, 08:54 PM
  4. DCount and SQL
    By DSTR3 in forum Queries
    Replies: 3
    Last Post: 12-06-2010, 03:07 PM
  5. no option to import xls file or option all files
    By captgnvr in forum Import/Export Data
    Replies: 3
    Last Post: 09-22-2009, 10:19 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