I'd appreciate some help. What I'm doing is fairly simple and I have done this in the past but I keep getting error 424 Object required.
I have form1 based on a table. A button links to a small form with 1 textbox (unbound) where the user types the text they want to search for. On Enter, they return to that record in form1. I have taken the code from another database where it works fine but in this one I get the error message.
Here's my code:
Dim rst, rst2 As Recordset
Dim db As Database
Global whichForm As Form
Global searchTxt, whichplName As String
Global search as Integer
If IsLoaded(Me.Name) Then
Set db = CurrentDb
Set rst = whichForm.RecordsetClone
' debug.print rst.name at this point gives table name
If Not rst Is Nothing Then
Set rst = Nothing
Set db = Nothing
click button on form1:
DoCmd.OpenForm "findPlacename", acNormal
textbox on form2 after update:
whichPlName = text1.text
search = 1
If search = 1 Then
searchTxt = "Gaelic = '" & whichplName & "'"
rst.FindFirst searchTxt ' error here
If rst.NoMatch Then
MsgBox ("Sorry, can't find that placename")
Me.Bookmark = rst.Bookmark
search = 0
DoCmd.Close acForm, "findPlacename"
Public Function IsLoaded(ByVal form_name As String) As Boolean
' found this on this forum - thank you
Dim frm As Form
' Return True if a form is loaded.
IsLoaded = False
For Each frm In Forms
If frm.Name = form_name Then
IsLoaded = True
Set whichForm = Forms(frm.Name)