By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,805 Members | 1,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,805 IT Pros & Developers. It's quick & easy.

New "Blank" Record Added When Search Runs

P: 48
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
Jun 12 '08 #1
Share this Question
Share on Google+
5 Replies


puppydogbuddy
Expert 100+
P: 1,923
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
Jun 12 '08 #2

P: 48
Here is the Code for the 2nd form:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CboTitleSearch_AfterUpdate()
  2.     Me![TxtTitleSearch] = Me![CboTitleSearch].Column(1)
  3. End Sub
  4.  
  5. Private Sub cboPublisherSearch_AfterUpdate()
  6.     Me![TxtPublisherSearch] = Me![CboPublisherSearch].Column(1)
  7. End Sub
  8.  
  9. Private Sub CmdSearch_Click()
  10. On Error GoTo Err_CmdSearch_Click
  11.         Dim stTitle As String
  12.         stTitle = "Records_Search_Query"
  13.  
  14.         CboTitleSearch.SetFocus
  15.         Me![CboTitleSearch] = ""
  16.         subfrmTitleSearch.Visible = True
  17.         LblTitleResults.Visible = True
  18.         Forms![Records_Search]![subfrmTitleSearch].Requery
  19.  
  20. Exit_CmdSearch_Click:
  21.     Exit Sub
  22.  
  23. Err_CmdSearch_Click:
  24.     MsgBox Err.Description
  25.     Resume Exit_CmdSearch_Click
  26.  
  27. End Sub
  28.  
  29. Private Sub CmdPublisherSearch_Click()
  30. On Error GoTo Err_CmdPublisherSearch_Click
  31.  
  32.     Dim stPublisher As String
  33.     stPublisher = "Publisher_Records_Search"
  34.  
  35.     CboPublisherSearch.SetFocus
  36.     Me![CboPublisherSearch] = ""
  37.     subfrmPubSearch.Visible = True
  38.     lblPubResults.Visible = True
  39.     Forms![Records_Search]![subfrmPubSearch].Requery
  40.  
  41. Exit_CmdPublisherSearch_Click:
  42.     Exit Sub
  43.  
  44. Err_CmdPublisherSearch_Click:
  45.     MsgBox Err.Description
  46.     Resume Exit_CmdPublisherSearch_Click
  47.  
  48. End Sub
  49.  
  50. Private Sub cmdSubmitted_Click()
  51. On Error GoTo Err_cmdSubmitted_Click
  52.  
  53.      If Me![txtSubmissions] = "Yes" Then
  54.         Dim stSubmitted As String
  55.         stSubmitted = "Records_Search_Submitted"
  56.      End If
  57.  
  58.     subfrmSubmissions.Visible = True
  59.     lblSubResults.Visible = True
  60.     Forms![Records_Search]![subfrmSubmissions].Requery
  61.  
  62. Exit_cmdSubmitted_Click:
  63.     Exit Sub
  64.  
  65. Err_cmdSubmitted_Click:
  66.     MsgBox Err.Description
  67.     Resume Exit_cmdSubmitted_Click
  68. End Sub
  69.  
  70. Private Sub CmdUnsubmitted_Click()
  71. On Error GoTo Err_CmdUnsubmitted_Click
  72.  
  73.      If Me![txtSubmissions] = "No" Then
  74.         Dim stUnsubmitted As String
  75.         stUnsubmitted = "Records_Search_Unsubmitted"
  76.      End If
  77.  
  78.      subfrmUnsubmitted.Visible = True
  79.      lblSubResults.Visible = True
  80.      Forms![Records_Search]![subfrmUnsubmitted].Requery
  81.  
  82. Exit_CmdUnsubmitted_Click:
  83.     Exit Sub
  84.  
  85. Err_CmdUnsubmitted_Click:
  86.     MsgBox Err.Description
  87.     Resume Exit_CmdUnsubmitted_Click
  88.  
  89. End Sub
  90.  
  91. Private Sub CmdCancelSearch_Click()
  92. On Error GoTo Err_CmdCancelSearch_Click
  93.  
  94.     Me![CboTitleSearch] = ""
  95.     Me![CboPublisherSearch] = ""
  96.     Me![TxtTitleSearch] = ""
  97.     Me![TxtPublisherSearch] = ""
  98.  
  99. Exit_CmdCancelSearch_Click:
  100.     Exit Sub
  101.  
  102. Err_CmdCancelSearch_Click:
  103.     MsgBox Err.Description
  104.     Resume Exit_CmdCancelSearch_Click
  105.  
  106. End Sub
  107. Private Sub CmdClearForm_Click()
  108. On Error GoTo Err_CmdClearForm_Click
  109.  
  110.     Me![CboTitleSearch] = ""
  111.     Me![CboPublisherSearch] = ""
  112.     Me![TxtTitleSearch] = ""
  113.     Me![TxtPublisherSearch] = ""
  114.     Me![txtSubmissions] = ""
  115.     CboTitleSearch.SetFocus
  116.     subfrmTitleSearch.Visible = False
  117.     LblTitleResults.Visible = False
  118.     subfrmPubSearch.Visible = False
  119.     lblPubResults.Visible = False
  120.     subfrmSubmissions.Visible = False
  121.     subfrmUnsubmitted.Visible = False
  122.     lblSubResults.Visible = False
  123.     RadNo = False
  124.     RadYes = False
  125.  
  126. Exit_CmdClearForm_Click:
  127.     Exit Sub
  128.  
  129. Err_CmdClearForm_Click:
  130.     MsgBox Err.Description
  131.     Resume Exit_CmdClearForm_Click
  132.  
  133. End Sub
  134.  
  135. Private Sub RadNo_Click()
  136.     cmdSubmitted.Visible = False
  137.     CmdUnsubmitted.Visible = True
  138.     CmdUnsubmitted.SetFocus
  139.     Me![txtSubmissions] = "No"
  140.     RadYes = False
  141.  
  142. End Sub
  143.  
  144. Private Sub RadYes_Click()
  145.     CmdUnsubmitted.Visible = False
  146.     cmdSubmitted.Visible = True
  147.     cmdSubmitted.SetFocus
  148.     Me![txtSubmissions] = "Yes"
  149.     RadNo = False
  150.  
  151. End Sub
  152. Private Sub cmdExit_Click()
  153. On Error GoTo Err_cmdExit_Click
  154.  
  155.  
  156.     DoCmd.Close
  157.  
  158. Exit_cmdExit_Click:
  159.     Exit Sub
  160.  
  161. Err_cmdExit_Click:
  162.     MsgBox Err.Description
  163.     Resume Exit_cmdExit_Click
  164.  
  165. End Sub
  166.  
Here are the SQL statements for each query called in thie above code

Records_Search_Query
Expand|Select|Wrap|Line Numbers
  1. 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]
  2. FROM Created_Submitted
  3. WHERE (((Created_Submitted.Title)=Forms!Records_Search!TxtTitleSearch));
  4.  
Publisher_Records_Search
Expand|Select|Wrap|Line Numbers
  1. SELECT Created_Submitted.[Submitted To], Created_Submitted.Title, Created_Submitted.[Date Submitted], Created_Submitted.Type, Created_Submitted.Accepted
  2. FROM Created_Submitted
  3. WHERE Forms!Records_Search!TxtPublisherSearch=(Created_Submitted.[Submitted To])
  4. GROUP BY Created_Submitted.[Submitted To], Created_Submitted.Title, Created_Submitted.[Date Submitted], Created_Submitted.Type, Created_Submitted.Accepted;
  5.  
Records_Search_Submitted
Expand|Select|Wrap|Line Numbers
  1. 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]
  2. FROM Created_Submitted
  3. WHERE (((Created_Submitted.Submitted)="yes"))
  4. 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];
  5.  
Records_Search_Unsubmitted
Expand|Select|Wrap|Line Numbers
  1. 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]
  2. FROM Created_Submitted
  3. WHERE (((Created_Submitted.Submitted)="no"))
  4. 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];
  5.  
Anything you can tell me would be greatly appreciated. I have searched online but not really found anything good.

Thanks,
Doug

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
Jun 12 '08 #3

puppydogbuddy
Expert 100+
P: 1,923
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
Jun 12 '08 #4

P: 48
Its actaully a form with some subforms on it. I'll check out the link.

Thanks

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
Jun 12 '08 #5

P: 48
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.

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

Thanks
Jun 13 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.