If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
SetFocus not working
I have a button that invokes code onClick and the last line of the
code ask for SetFocus on a control, but for some reason it is not doing it - sort of. After clicking the button, I cannot find the cursor anywhere. If I hit the TAB key, nothing happens. So then, if I click on a blank part of the form (not on a control) then the cursor shows up in the field that is supposed to get the focus. So it almost as if the entire form is losing focus. Here is the code: Private Sub ImportData_Click() On Error Resume Next Dim stSpec, stTable, stFileName As String stSpec = "Prospect Import" stTable = "Prospects" stFileName = "C:\Documents and Settings\mkline\Desktop\import.csv" DoCmd.TransferText acImportDelim, stSpec, stTable, stFileName DoCmd.Requery Me.FindCompany.SetFocus 'DoCmd.RunCommand acCmdImport End Sub In case it matters, this button is on a subform (Research). The parent form is Prospects. However, the button and the control that is seeking the focus are both on the subform. Does anyone know what is happening here? Thanks in advance! magmike |
#2
|
|||
|
|||
SetFocus not working
Strange. I would think that would work
Try Me.SetFocus ME.FindCompany.SetFocus Or go all out and try Forms!MainFormName.SubFormControlName.SetFocus Forms!MainFormName.SubformControlName.Form!FindCom pany.SetFocus John Spencer Access MVP 2002-2005, 2007-2008 The Hilltop Institute University of Maryland Baltimore County magmike wrote: I have a button that invokes code onClick and the last line of the code ask for SetFocus on a control, but for some reason it is not doing it - sort of. After clicking the button, I cannot find the cursor anywhere. If I hit the TAB key, nothing happens. So then, if I click on a blank part of the form (not on a control) then the cursor shows up in the field that is supposed to get the focus. So it almost as if the entire form is losing focus. Here is the code: Private Sub ImportData_Click() On Error Resume Next Dim stSpec, stTable, stFileName As String stSpec = "Prospect Import" stTable = "Prospects" stFileName = "C:\Documents and Settings\mkline\Desktop\import.csv" DoCmd.TransferText acImportDelim, stSpec, stTable, stFileName DoCmd.Requery Me.FindCompany.SetFocus 'DoCmd.RunCommand acCmdImport End Sub In case it matters, this button is on a subform (Research). The parent form is Prospects. However, the button and the control that is seeking the focus are both on the subform. Does anyone know what is happening here? Thanks in advance! magmike |
#3
|
|||
|
|||
SetFocus not working
On Oct 21, 3:21*pm, John Spencer wrote:
Strange. I would think that would work Try * Me.SetFocus * ME.FindCompany.SetFocus Or go all out and try * *Forms!MainFormName.SubFormControlName.SetFocus * *Forms!MainFormName.SubformControlName.Form!FindCo mpany.SetFocus John Spencer Access MVP 2002-2005, 2007-2008 The Hilltop Institute University of Maryland Baltimore County magmikewrote: I have a button that invokes code onClick and the last line of the code ask for SetFocus on a control, but for some reason it is not doing it - sort of. After clicking the button, I cannot find the cursor anywhere. If I hit the TAB key, nothing happens. So then, if I click on a blank part of the form (not on a control) then the cursor shows up in the field that is supposed to get the focus. So it almost as if the entire form is losing focus. Here is the code: Private Sub ImportData_Click() On Error Resume Next Dim stSpec, stTable, stFileName As String stSpec = "Prospect Import" stTable = "Prospects" stFileName = "C:\Documents and Settings\mkline\Desktop\import.csv" * * DoCmd.TransferText acImportDelim, stSpec, stTable, stFileName * * DoCmd.Requery Me.FindCompany.SetFocus * * 'DoCmd.RunCommand acCmdImport End Sub In case it matters, this button is on a subform (Research). The parent form is Prospects. However, the button and the control that is seeking the focus are both on the subform. Does anyone know what is happening here? Thanks in advance! magmike- Hide quoted text - - Show quoted text - I tried both of those and various other like-minded combinations. None of them worked. However, I did find two things that do work. I may try to find other ways just for the hell of it. However, the basic premise is doing something off form. The first (and least desirable) was adding the following: DoCmd.Minimize DoCmd.Maximize Me.FindCompany.SetFocus That works, but it is messy in that the form disappears and then reappears. However, the second it a lot less noticable. I create a form that simply displays the words "One moment please..." and then closes itself after 5 (I thought it was seconds, but it must be way less because I barely see a blip." In the new form after closing is where I located the instruction to set the focus on Forms! ProsectForm!Research.Form!FindCompany That is what I will go with for now. Thanks for your help! magmike |
Thread Tools | |
Display Modes | |
|
|