troubleshooting Question

DoCmd.GoToRecord reporting form not opened error (was working)

Avatar of schmir1
schmir1Flag for United States of America asked on
Microsoft Access
10 Comments1 Solution361 ViewsLast Modified:
I'm having trouble with the GoToRecord command.  It was working then I change a line below the GoToRecord line and now I'm getting an error on.  I think some thing is unstable.  Here is the line that generates the error:
  DoCmd.GoToRecord acDataForm, "BOM Parts Subform", acGoTo, 2

Here is the error:
    Error Number 2489
    The object 'BOM Parts Subform' isn't open.

Here is the entire routine:
  Dim strQuery As String
  Dim strFindDesWild As String
  strFindDes = RTrim(InputBox("Please enter search string", "Search Designator field ONLY", strFindDes))
  If strFindDes = "" Then
    Exit Sub
  End If
  strFindDesWild = """" & "*" & strFindDes & "*" & """"
  strQuery = "SELECT [BOM Parts].[BOM Parts ID] FROM [BOM Parts] INNER JOIN [BOM Designators] ON" & _
             " [BOM Parts].[BOM Parts ID] = [BOM Designators].[BOM Parts ID]" & _
             " WHERE [BOM Parts].[BOM ID] = " & Parent.txtBOMID & _
             " AND [BOM Designators].Designator Like " & strFindDesWild & _
             " ORDER BY [BOM Parts].[BOM Parts ID]"
  Set rstBOMDes = CurrentDb.OpenRecordset(strQuery, dbOpenSnapshot)
  DoCmd.GoToRecord acDataForm, "BOM Parts Subform", acGoTo, 2    '<--------------Error here
  If rstBOMDes.EOF Then
    MsgBox """" & strFindDes & """ " & " not found in Designator fields" & vbNewLine & _
           "Note: Use the ""Find"" button below to search Component, Description, or Comments fields", vbInformation, "User Notice (BPS-11)"
'    DoCmd.FindRecord rstBOMDes![BOM Parts ID], acAnywhere, , acSearchAll, , acAll  '<-original line
    DoCmd.FindRecord rstBOMDes![BOM Parts ID], acAnywhere, , acSearchAll, True, acAll  'added Search As '< New Line
  End If
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros