recently input data cannot be searched from frontend

mrmarc

Board Regular
Joined
Feb 3, 2014
Messages
79
So Im using this code in pop up on a front end data base.

Code:
Private Sub btnSearch_Click()

Dim rst As Object


Set rst = Me.RecordsetClone
 
rst.FindFirst "[PalletNumber]=" & Me!cboRawInput
 
If rst.NoMatch Then
   MsgBox "Record Not Found"
Else
   Me.Bookmark = rst.Bookmark
End If
 
rst.Close
Set rst = Nothing


Me.Refresh


[Forms]![FloorLogistics]![NavigationSubform].[Form].Refresh


End Sub

It works fine, except when new records are inputted into the table that the code is searching in the backend. I search for the new records and I get the "NoMatch" message: "No Record Found". BUT when I close down this frontend and open it again I can search the new records.

Is there a way I can search the new records without having to close and open my frontend database?

Thanks,
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Using Refresh is be part of the problem. You need to use Requrey to get new records.

Refresh: - updates just the records currently in the recordset. No new records are added since the recordset was was originally generated.

Requery - executes the recordset generation again (same effect as closing a form or report and opening it again). This will add any new records added after the recordset was originally generated.

I would try this:

Code:
Private Sub btnSearch_Click()

Dim rst As Object

Me.Requery ' <<<< load any new records before searching
  
Set rst = Me.RecordsetClone 
 
rst.FindFirst "[PalletNumber]=" & Me!cboRawInput
 
If rst.NoMatch Then
   MsgBox "Record Not Found"
Else
   Me.Bookmark = rst.Bookmark
End If
 
rst.Close
Set rst = Nothing


[Forms]![FloorLogistics]![NavigationSubform].[Form].Requery   ' Use requery to add new records and remove deleted

End Sub
 
Upvote 0

Forum statistics

Threads
1,221,889
Messages
6,162,627
Members
451,778
Latest member
ragananthony7911

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top