Hi,
I have been fiddling with my database and I need some help.
It’s not the easiest thing to explain but here goes…
I have a main menu with a tree view on the left. When the user clicks on an item in here, I have different forms appearing. For example if the user clicks on the top level, they will get a different form than if they click on the second level.
I am detecting which level they are clicking on and showing the correct form on the right.
I have one form visible and another invisible. When I need to change the form on the right, I make it visible, set it to have the focus and then set the old form to invisible. When I do this, I get an error saying
“Run time error ‘2449’ ”
“There is an invalid method in an expression”
The line it crashes on is
Form_frmOne.SetFocus
I have tried setting the focus to other things like text boxes. When I do this, then try to make the form invisible, it comes up with;
“Run time error ‘2165 ”
“You cant hide a control that has the focus”
On the following line
Form_frmTwo.Visible = False
And I know the focus is on a textbox before I do this because I can look at the form and see where the cursor is blinking.
I have done this before on a simpler database but I think access is getting confused because I am using sub forms and tab controls. Should using these affect my code?
The code on the tree view click looks like the following.
If selected = "SectorData" Then
sValue = Me.SectorText.Value
sValue2 = Me.SectionText.Value
sCriteria = " WHERE [tblSector.SectionName] = "
sCriteria = sCriteria + "'" & sValue & "'"
sCriteria = sCriteria + " AND [tblSection.SectionName] = "
sCriteria = sCriteria + "'" & sValue2 & "'"
Me.Text55.SetFocus
Form_frmOne.Visible = True
Form_ frmOne.SetFocus
Form_ frmTwo.Visible = False '2
sSql = "SELECT * from qrySectionLevel " & sCriteria
Form_ frmOne.Form.RecordSource = sSql
Form_ frmOne.Form.Requery
End If
If anyone could help, I would be very grateful.
Thanks,
Joe.
I have been fiddling with my database and I need some help.
It’s not the easiest thing to explain but here goes…
I have a main menu with a tree view on the left. When the user clicks on an item in here, I have different forms appearing. For example if the user clicks on the top level, they will get a different form than if they click on the second level.
I am detecting which level they are clicking on and showing the correct form on the right.
I have one form visible and another invisible. When I need to change the form on the right, I make it visible, set it to have the focus and then set the old form to invisible. When I do this, I get an error saying
“Run time error ‘2449’ ”
“There is an invalid method in an expression”
The line it crashes on is
Form_frmOne.SetFocus
I have tried setting the focus to other things like text boxes. When I do this, then try to make the form invisible, it comes up with;
“Run time error ‘2165 ”
“You cant hide a control that has the focus”
On the following line
Form_frmTwo.Visible = False
And I know the focus is on a textbox before I do this because I can look at the form and see where the cursor is blinking.
I have done this before on a simpler database but I think access is getting confused because I am using sub forms and tab controls. Should using these affect my code?
The code on the tree view click looks like the following.
If selected = "SectorData" Then
sValue = Me.SectorText.Value
sValue2 = Me.SectionText.Value
sCriteria = " WHERE [tblSector.SectionName] = "
sCriteria = sCriteria + "'" & sValue & "'"
sCriteria = sCriteria + " AND [tblSection.SectionName] = "
sCriteria = sCriteria + "'" & sValue2 & "'"
Me.Text55.SetFocus
Form_frmOne.Visible = True
Form_ frmOne.SetFocus
Form_ frmTwo.Visible = False '2
sSql = "SELECT * from qrySectionLevel " & sCriteria
Form_ frmOne.Form.RecordSource = sSql
Form_ frmOne.Form.Requery
End If
If anyone could help, I would be very grateful.
Thanks,
Joe.