rainsworth
Programmer
Trying to set focus to a form using a variable. Here is the code. - Thanks
Set dbs = CurrentDb
Set RST = dbs.OpenRecordset("Functions"
Function_name = Trim(Forms!Main_menu.FunctionsCMB.Value)
Form_Name = Trim(RST.Fields!form_alias.Value)
RST.MoveFirst
Do While Not RST.EOF
If Function_name = Trim(RST.Fields![User/Manage_Functions].Value) Then
DoCmd.OpenForm (Form_Name) ' This works !
Forms!Main_menu.SetFocus
DoCmd.Close
Forms!(Form_Name).SetFocus ' This does not work
RST.MoveLast
RST.MoveNext
Else
RST.MoveNext
End If
Loop
End Sub
Set dbs = CurrentDb
Set RST = dbs.OpenRecordset("Functions"
Function_name = Trim(Forms!Main_menu.FunctionsCMB.Value)
Form_Name = Trim(RST.Fields!form_alias.Value)
RST.MoveFirst
Do While Not RST.EOF
If Function_name = Trim(RST.Fields![User/Manage_Functions].Value) Then
DoCmd.OpenForm (Form_Name) ' This works !
Forms!Main_menu.SetFocus
DoCmd.Close
Forms!(Form_Name).SetFocus ' This does not work
RST.MoveLast
RST.MoveNext
Else
RST.MoveNext
End If
Loop
End Sub