schmir1
asked on
DoCmd.GoToRecord reporting form not opened error (was working)
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(st rQuery, 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)"
Else
Me.txtBOMPartsID.SetFocus
' 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
Me.txtComponentNum.SetFocu s
End If
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(st
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)"
Else
Me.txtBOMPartsID.SetFocus
' 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
Me.txtComponentNum.SetFocu
End If
ASKER
I get the same error.
what was the original line?
That's the funny thing. That is the original line. It use to work. I just started getting this error. The only changes I made are changing the line below and deleting a completely different form. I'm thinking maybe deleting the other form screwed up something.
what was the original line?
That's the funny thing. That is the original line. It use to work. I just started getting this error. The only changes I made are changing the line below and deleting a completely different form. I'm thinking maybe deleting the other form screwed up something.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
When I do the "Me." , I get a list of everything available but not "BOM Parts Subform". If the menu, I pick View Object and I get to "BOM Parts Subform". Something is screwy.
In your main form's design view - click once on the subform (and only once - we want the control selected).
View>Properties. What is its Name?
That's what you need to be using.
View>Properties. What is its Name?
That's what you need to be using.
ASKER
I get the following:
BOM Parts Subform
When I try that name in your suggestions above, I get an error:
Error Number 2465
MCL Database Application *DEVEL* (From Rev. 3.4 to 3.5) 2/26/07 can't find the field 'Forms' referred to in your expression.
I'm going to try my old standby and copy the form then see if it starts to work.
BOM Parts Subform
When I try that name in your suggestions above, I get an error:
Error Number 2465
MCL Database Application *DEVEL* (From Rev. 3.4 to 3.5) 2/26/07 can't find the field 'Forms' referred to in your expression.
I'm going to try my old standby and copy the form then see if it starts to work.
ASKER
My copy fix didn't help. I think I'll give up on this and take the DoCmd.GoToRecord out. The find works but not as reliably.
And you're sure you're refering to the name of the subform control?
If you take out the GotoRecord line - does focus move to the subform, or does it still throw an error?
If you take out the GotoRecord line - does focus move to the subform, or does it still throw an error?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks GreymanMSC. The following still didn't work:
Me![BOM Parts Subform].Form.Recordset.Mo veFirst
Me![BOM Parts Subform].Form.Recordset.Mo veNext
There is just no way use "BOM Parts Subform" even though I can go to the object and the code window also says "Form_BOM Parts Subform"
Anyhow, I'm using the following that you provided:
Me.Recordset.FindFirst "[BOM Parts ID] = " & rstBOMDes![BOM Parts ID].Value
This seems to make the find more reliable.
Thanks for all your help.
Me![BOM Parts Subform].Form.Recordset.Mo
Me![BOM Parts Subform].Form.Recordset.Mo
There is just no way use "BOM Parts Subform" even though I can go to the object and the code window also says "Form_BOM Parts Subform"
Anyhow, I'm using the following that you provided:
Me.Recordset.FindFirst "[BOM Parts ID] = " & rstBOMDes![BOM Parts ID].Value
This seems to make the find more reliable.
Thanks for all your help.
DoCmd.GoToRecord acDataForm, "Forms!NameOFMainForm.[BOM
what was the original line?