New "Blank" Record Added When Search Runs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dougmeece
    New Member
    • Feb 2008
    • 48

    New "Blank" Record Added When Search Runs

    I have two forms with one calling the other to perform searches. When I run the search form the 2nd form a blank record is added to my table. The table is appended or updated from entries on the first form but the second form doesn’t reference the table at all. The queries ran from the form obviously query the table for data but these are not the same queries that update/append.

    Any ideas what would cause this to happen?

    As always, any help would be greatly appreciated.

    Thanks,
    Doug
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    Doug,
    Check the property sheet for the second form and make sure data entry is set to No. If that doesn't fix it, then please post the code sub that you use to open the second form.

    PDB

    Comment

    • dougmeece
      New Member
      • Feb 2008
      • 48

      #3
      Here is the Code for the 2nd form:

      Code:
      Private Sub CboTitleSearch_AfterUpdate()
          Me![TxtTitleSearch] = Me![CboTitleSearch].Column(1)
      End Sub
      
      Private Sub cboPublisherSearch_AfterUpdate()
          Me![TxtPublisherSearch] = Me![CboPublisherSearch].Column(1)
      End Sub
      
      Private Sub CmdSearch_Click()
      On Error GoTo Err_CmdSearch_Click
              Dim stTitle As String
              stTitle = "Records_Search_Query"
                            
              CboTitleSearch.SetFocus
              Me![CboTitleSearch] = ""
              subfrmTitleSearch.Visible = True
              LblTitleResults.Visible = True
              Forms![Records_Search]![subfrmTitleSearch].Requery
             
      Exit_CmdSearch_Click:
          Exit Sub
      
      Err_CmdSearch_Click:
          MsgBox Err.Description
          Resume Exit_CmdSearch_Click
      
      End Sub
      
      Private Sub CmdPublisherSearch_Click()
      On Error GoTo Err_CmdPublisherSearch_Click
          
          Dim stPublisher As String
          stPublisher = "Publisher_Records_Search"
                 
          CboPublisherSearch.SetFocus
          Me![CboPublisherSearch] = ""
          subfrmPubSearch.Visible = True
          lblPubResults.Visible = True
          Forms![Records_Search]![subfrmPubSearch].Requery
                     
      Exit_CmdPublisherSearch_Click:
          Exit Sub
      
      Err_CmdPublisherSearch_Click:
          MsgBox Err.Description
          Resume Exit_CmdPublisherSearch_Click
          
      End Sub
      
      Private Sub cmdSubmitted_Click()
      On Error GoTo Err_cmdSubmitted_Click
      
           If Me![txtSubmissions] = "Yes" Then
              Dim stSubmitted As String
              stSubmitted = "Records_Search_Submitted"
           End If
          
          subfrmSubmissions.Visible = True
          lblSubResults.Visible = True
          Forms![Records_Search]![subfrmSubmissions].Requery
          
      Exit_cmdSubmitted_Click:
          Exit Sub
      
      Err_cmdSubmitted_Click:
          MsgBox Err.Description
          Resume Exit_cmdSubmitted_Click
      End Sub
      
      Private Sub CmdUnsubmitted_Click()
      On Error GoTo Err_CmdUnsubmitted_Click
      
           If Me![txtSubmissions] = "No" Then
              Dim stUnsubmitted As String
              stUnsubmitted = "Records_Search_Unsubmitted"
           End If
           
           subfrmUnsubmitted.Visible = True
           lblSubResults.Visible = True
           Forms![Records_Search]![subfrmUnsubmitted].Requery
         
      Exit_CmdUnsubmitted_Click:
          Exit Sub
      
      Err_CmdUnsubmitted_Click:
          MsgBox Err.Description
          Resume Exit_CmdUnsubmitted_Click
          
      End Sub
      
      Private Sub CmdCancelSearch_Click()
      On Error GoTo Err_CmdCancelSearch_Click
      
          Me![CboTitleSearch] = ""
          Me![CboPublisherSearch] = ""
          Me![TxtTitleSearch] = ""
          Me![TxtPublisherSearch] = ""
          
      Exit_CmdCancelSearch_Click:
          Exit Sub
      
      Err_CmdCancelSearch_Click:
          MsgBox Err.Description
          Resume Exit_CmdCancelSearch_Click
          
      End Sub
      Private Sub CmdClearForm_Click()
      On Error GoTo Err_CmdClearForm_Click
      
          Me![CboTitleSearch] = ""
          Me![CboPublisherSearch] = ""
          Me![TxtTitleSearch] = ""
          Me![TxtPublisherSearch] = ""
          Me![txtSubmissions] = ""
          CboTitleSearch.SetFocus
          subfrmTitleSearch.Visible = False
          LblTitleResults.Visible = False
          subfrmPubSearch.Visible = False
          lblPubResults.Visible = False
          subfrmSubmissions.Visible = False
          subfrmUnsubmitted.Visible = False
          lblSubResults.Visible = False
          RadNo = False
          RadYes = False
                   
      Exit_CmdClearForm_Click:
          Exit Sub
      
      Err_CmdClearForm_Click:
          MsgBox Err.Description
          Resume Exit_CmdClearForm_Click
          
      End Sub
      
      Private Sub RadNo_Click()
          cmdSubmitted.Visible = False
          CmdUnsubmitted.Visible = True
          CmdUnsubmitted.SetFocus
          Me![txtSubmissions] = "No"
          RadYes = False
          
      End Sub
      
      Private Sub RadYes_Click()
          CmdUnsubmitted.Visible = False
          cmdSubmitted.Visible = True
          cmdSubmitted.SetFocus
          Me![txtSubmissions] = "Yes"
          RadNo = False
          
      End Sub
      Private Sub cmdExit_Click()
      On Error GoTo Err_cmdExit_Click
      
      
          DoCmd.Close
      
      Exit_cmdExit_Click:
          Exit Sub
      
      Err_cmdExit_Click:
          MsgBox Err.Description
          Resume Exit_cmdExit_Click
          
      End Sub
      Here are the SQL statements for each query called in thie above code

      Records_Search_ Query
      Code:
      SELECT Created_Submitted.Title, Created_Submitted.[Year Created], Created_Submitted.Submitted, Created_Submitted.[Submitted To], Created_Submitted.Website, Created_Submitted.Type, Created_Submitted.Accepted, Created_Submitted.[Date Submitted], [Date Entered]
      FROM Created_Submitted
      WHERE (((Created_Submitted.Title)=Forms!Records_Search!TxtTitleSearch));
      Publisher_Recor ds_Search
      Code:
      SELECT Created_Submitted.[Submitted To], Created_Submitted.Title, Created_Submitted.[Date Submitted], Created_Submitted.Type, Created_Submitted.Accepted
      FROM Created_Submitted
      WHERE Forms!Records_Search!TxtPublisherSearch=(Created_Submitted.[Submitted To])
      GROUP BY Created_Submitted.[Submitted To], Created_Submitted.Title, Created_Submitted.[Date Submitted], Created_Submitted.Type, Created_Submitted.Accepted;
      Records_Search_ Submitted
      Code:
      SELECT Created_Submitted.Title, Created_Submitted.[Year Created], Created_Submitted.Submitted, Created_Submitted.[Submitted To], Created_Submitted.Website, Created_Submitted.Type, Created_Submitted.Accepted, Created_Submitted.[Date Submitted], Created_Submitted.[Date Entered]
      FROM Created_Submitted
      WHERE (((Created_Submitted.Submitted)="yes"))
      GROUP BY Created_Submitted.Title, Created_Submitted.[Year Created], Created_Submitted.Submitted, Created_Submitted.[Submitted To], Created_Submitted.Website, Created_Submitted.Type, Created_Submitted.Accepted, Created_Submitted.[Date Submitted], Created_Submitted.[Date Entered];
      Records_Search_ Unsubmitted
      Code:
      SELECT Created_Submitted.Title, Created_Submitted.[Year Created], Created_Submitted.Submitted, Created_Submitted.[Submitted To], Created_Submitted.Website, Created_Submitted.Type, Created_Submitted.Accepted, Created_Submitted.[Date Submitted], Created_Submitted.[Date Entered]
      FROM Created_Submitted
      WHERE (((Created_Submitted.Submitted)="no"))
      GROUP BY Created_Submitted.Title, Created_Submitted.[Year Created], Created_Submitted.Submitted, Created_Submitted.[Submitted To], Created_Submitted.Website, Created_Submitted.Type, Created_Submitted.Accepted, Created_Submitted.[Date Submitted], Created_Submitted.[Date Entered];
      Anything you can tell me would be greatly appreciated. I have searched online but not really found anything good.

      Thanks,
      Doug

      Originally posted by puppydogbuddy
      Doug,
      Check the property sheet for the second form and make sure data entry is set to No. If that doesn't fix it, then please post the code sub that you use to open the second form.

      PDB

      Comment

      • puppydogbuddy
        Recognized Expert Top Contributor
        • May 2007
        • 1923

        #4
        Doug,
        I don't have the time to study all that code in detail, but it looks to me that the second form you refer is really a subform. In that case, they go together like bread and butter.....when a main form record is created, so will the subform be created. No so if you are using 2 forms. Suggest that you download sample forms (includes an example of a form w/subform, and an example of 2 forms working in synchronized fashion) from this link:

        Comment

        • dougmeece
          New Member
          • Feb 2008
          • 48

          #5
          Its actaully a form with some subforms on it. I'll check out the link.

          Thanks

          Originally posted by puppydogbuddy
          Doug,
          I don't have the time to study all that code in detail, but it looks to me that the second form you refer is really a subform. In that case, they go together like bread and butter.....when a main form record is created, so will the subform be created. No so if you are using 2 forms. Suggest that you download sample forms (includes an example of a form w/subform, and an example of 2 forms working in synchronized fashion) from this link:

          http://support.microsoft.com/kb/233324

          Comment

          • dougmeece
            New Member
            • Feb 2008
            • 48

            #6
            I have this fixed. Turns out it was two things. One the form was not set with the proper data source. Second, the query was not setup properly. Once I change those two things it stopped adding the blank record.

            Thanks for the help.

            Originally posted by dougmeece
            Its actaully a form with some subforms on it. I'll check out the link.

            Thanks

            Comment

            Working...