Что может быть причиной установки фокуса в Access 2010/VBA, кроме SetFocus?

У меня есть непрерывная подчиненная форма, которая берет свои данные из одного из двух запросов в зависимости от значения строки.

При первом запросе фокус устанавливается на первое текстовое поле (Prospect_Name) первой строки, как и ожидалось. Я не использую SetFocus, чтобы установить фокус здесь, это то, что он выбирает автоматически.

Со вторым, фокус устанавливается на другое текстовое поле первой строки (ID), что вызывает у меня всевозможные проблемы - у меня нет горизонтальных полос прокрутки, и это меню предназначено для "offscreeen", но если для него установлен фокус, подчиненная форма автоматически прокручивается до этого значения. Фокус всегда установлен на это текстовое поле. Это не последний горизонтально или что-то в этом роде.

Я проверил, и нет SetFocus, чтобы переместить фокус на ID, так зачем он это делает? Я предполагаю, что это должно быть связано со вторым запросом, так как это единственное, что изменилось? Второй запрос - это запрос объединения, может ли это быть виноват?

Запросы ниже, хотя они немного длинные, поэтому я не знаю, насколько они будут полезны.

Рабочий запрос:

SELECT Prospects.ID, Prospects.Company, Prospects.[Registered No], Prospects.[Limited Company], Prospects.[Originally Known As], Prospects.Office AS [BF Office], Prospects.Partner, Prospects.Partner2, Prospects.Partner3, Prospects.Status, Prospects.[SIC Code], Prospects.TPSMPS, Prospects.Website, Prospects.Sector, Prospects.[Turnover Bracket], Prospects.Turnover, Prospects.[Turnover Min], Prospects.[Turnover Max], Prospects.Accountant, Prospects.Bank, Prospects.Solicitor, Prospects.Employees, Prospects.[Audit Fee], Prospects.CharityType, Prospects.Sourceoffinancials, Prospects.DateCreated, Prospects.Createby, Prospects.DateModified, Prospects.Modifiedby, Prospects.[Key Contact], Prospects.[Address Type], Prospects.Address1, Prospects.Address2, Prospects.Address3, Prospects.Town, Prospects.County, Prospects.Postcode, Prospects.[Telephone Number], Prospects.Email, Prospects.[Incorrect Emails], Prospects.Telemarket, Prospects.Sourceofdata, Prospects.Clientcode, Prospects.DateConverted, Prospects.[Number of Beds in Group], Prospects.[Number of Homes in Group], Prospects.[Healthcare Type], Prospects.CharitiesT, Prospects.WManagementT, Prospects.CareT, Prospects.PropertyT, Prospects.LeisureTourismT, Prospects.MarineT, Prospects.MediaCreativeT, Prospects.ProPracticesT, Prospects.MotorT, Prospects.PersonalTaxT, Prospects.TaxT, Prospects.VATT, Prospects.PayrollT, Prospects.AuditT, Prospects.SAGET, Prospects.AccountsT, Prospects.CFinT, Prospects.BusinessRecoveryT, Prospects.ForensicT, Prospects.GrantT, Prospects.IFAT, Prospects.IntTaxT, Prospects.TaxInvT, Prospects.RenewablesT, Prospects.AcademiesT, Prospects.MTIT, [Prospects]![NextContact] AS NextContactA, Nz([NextContact],"~") AS NextContactNZ, Nz([Key Contacts]![Last Name],"zz") AS KeyContact1NZ, Nz([Key Contacts]![First Name],"~") AS KeyContact2NZ, Nz([Most Recent Contact]![SortA],"zz") AS DateNZ, [Most Recent Contact.SortA] AS DateA, [Most Recent Contact].Information AS [Note Full Info], [Key Contacts].[First Name], Prospects.[Holding Company], Prospects.[TPS/CTPS], Prospects.[Top 500], Prospects.NextContact, Prospects.[Payroll Status], [Key Contacts].[Key Contact E-Mail], [Key Contacts].[Key Contact], [Most Recent Contact].*, [Date] & IIf([Date] Is Not Null,": ","") & [Title] AS [Note Information], "N/A" AS [Filter Checker], Prospects.Company AS [Group], "Parent" AS [Parent / Child], [Most Recent Contact].[Added by] AS [Note author], Nz(Right((Left([NextContactA],10)),4) & Mid([NextContactA],4,2) & Left([NextContactA],2),"zz") AS NextContactSortA
    FROM ((Prospects LEFT JOIN [Key Contacts] ON Prospects.ID = [Key Contacts].ID) LEFT JOIN [Most Recent Contact] ON Prospects.ID = [Most Recent Contact].[Prospect ID]) INNER JOIN [Report - Holding Filter] ON Prospects.ID = [Report - Holding Filter].ID
    WHERE (((Prospects.Status) Not Like "Duplicate") AND ((Prospects.Company) Like "*" & [Forms]![Reports]![Search Text] & "*"))
    ORDER BY Prospects.Company;

Запрос, который вызывает проблему:

SELECT * FROM [SearchByName] UNION SELECT * FROM [SearchByName - GrandChildren];

Первая часть этого запроса (SearchByName) является предыдущим запросом, вторая часть ниже:

SELECT * FROM [SearchByName - Holding Companies] UNION SELECT * FROM [SearchByName - Level 1 subsidiaries];

Который сам состоит из следующих двух запросов:

SELECT [SearchByName - No Filter].ID, [SearchByName - No Filter].Company, [SearchByName - No Filter].[Registered No], [SearchByName - No Filter].[Limited Company], [SearchByName - No Filter].[Originally Known As], [SearchByName - No Filter].[BF Office], [SearchByName - No Filter].Partner, [SearchByName - No Filter].Partner2, [SearchByName - No Filter].Partner3, [SearchByName - No Filter].Status, [SearchByName - No Filter].[SIC Code], [SearchByName - No Filter].TPSMPS, [SearchByName - No Filter].Website, [SearchByName - No Filter].Sector, [SearchByName - No Filter].[Turnover Bracket], [SearchByName - No Filter].Turnover, [SearchByName - No Filter].[Turnover Min], [SearchByName - No Filter].[Turnover Max], [SearchByName - No Filter].Accountant, [SearchByName - No Filter].Bank, [SearchByName - No Filter].Solicitor, [SearchByName - No Filter].Employees, [SearchByName - No Filter].[Audit Fee], [SearchByName - No Filter].CharityType, [SearchByName - No Filter].Sourceoffinancials, [SearchByName - No Filter].DateCreated, [SearchByName - No Filter].Createby, [SearchByName - No Filter].DateModified, [SearchByName - No Filter].Modifiedby, [SearchByName - No Filter].Prospects.[Key Contact], [SearchByName - No Filter].[Address Type], [SearchByName - No Filter].Address1, [SearchByName - No Filter].Address2, [SearchByName - No Filter].Address3, [SearchByName - No Filter].Town, [SearchByName - No Filter].County, [SearchByName - No Filter].Postcode, [SearchByName - No Filter].[Telephone Number], [SearchByName - No Filter].Email, [SearchByName - No Filter].[Incorrect Emails], [SearchByName - No Filter].Telemarket, [SearchByName - No Filter].Sourceofdata, [SearchByName - No Filter].Clientcode, [SearchByName - No Filter].DateConverted, [SearchByName - No Filter].[Number of Beds in Group], [SearchByName - No Filter].[Number of Homes in Group], [SearchByName - No Filter].[Healthcare Type], [SearchByName - No Filter].CharitiesT, [SearchByName - No Filter].WManagementT, [SearchByName - No Filter].CareT, [SearchByName - No Filter].PropertyT, [SearchByName - No Filter].LeisureTourismT, [SearchByName - No Filter].MarineT, [SearchByName - No Filter].MediaCreativeT, [SearchByName - No Filter].ProPracticesT, [SearchByName - No Filter].MotorT, [SearchByName - No Filter].PersonalTaxT, [SearchByName - No Filter].TaxT, [SearchByName - No Filter].VATT, [SearchByName - No Filter].PayrollT, [SearchByName - No Filter].AuditT, [SearchByName - No Filter].SAGET, [SearchByName - No Filter].AccountsT, [SearchByName - No Filter].CFinT, [SearchByName - No Filter].BusinessRecoveryT, [SearchByName - No Filter].ForensicT, [SearchByName - No Filter].GrantT, [SearchByName - No Filter].IFAT, [SearchByName - No Filter].IntTaxT, [SearchByName - No Filter].TaxInvT, [SearchByName - No Filter].RenewablesT, [SearchByName - No Filter].AcademiesT, [SearchByName - No Filter].MTIT, [SearchByName - No Filter].NextContactA, [SearchByName - No Filter].NextContactNZ, [SearchByName - No Filter].KeyContact1NZ, [SearchByName - No Filter].KeyContact2NZ, [SearchByName - No Filter].DateNZ, [SearchByName - No Filter].DateA, [SearchByName - No Filter].[Note Full Info], [SearchByName - No Filter].[First Name], [SearchByName - No Filter].[Holding Company], [SearchByName - No Filter].[TPS/CTPS], [SearchByName - No Filter].[Top 500], [SearchByName - No Filter].NextContact, [SearchByName - No Filter].[Payroll Status], [SearchByName - No Filter].[Key Contact E-Mail], [SearchByName - No Filter].[Key Contacts].[Key Contact], [SearchByName - No Filter].[Lead ID], [SearchByName - No Filter].Information, [SearchByName - No Filter].[Prospect ID], [SearchByName - No Filter].Title, [SearchByName - No Filter].Date, [SearchByName - No Filter].Hyperlink, [SearchByName - No Filter].[Added by], [SearchByName - No Filter].SortA, [SearchByName - No Filter].[Note Information], [SearchByName - No Filter].[Filter Checker], [SearchByName - No Filter].Group, "Parent" AS [Parent / Child], [SearchByName - No Filter].[Added by] AS [Note Author], " " AS [Intentionally blank]
FROM [SearchByName - No Filter] INNER JOIN [SearchByName - Level 1 Subsidiaries] ON [SearchByName - No Filter].ID = [SearchByName - Level 1 Subsidiaries].[Holding Company];

а также

SELECT [SearchByName - No filter].ID, "     " & [Subsidiaries]![Company] & " (subsidiary of " & [SearchByName - No Filter]![Company] & ")" AS Company, Subsidiaries.[Registered No], [SearchByName - No filter].[Limited Company], [SearchByName - No filter].[Originally Known As], [SearchByName - No filter].[BF Office], [SearchByName - No filter].Partner, [SearchByName - No filter].Partner2, [SearchByName - No filter].Partner3, [SearchByName - No filter].Status, [SearchByName - No filter].[SIC Code], [SearchByName - No filter].TPSMPS, [SearchByName - No filter].Website, [SearchByName - No filter].Sector, [SearchByName - No filter].[Turnover Bracket], [SearchByName - No filter].Turnover, [SearchByName - No filter].[Turnover Min], [SearchByName - No filter].[Turnover Max], [SearchByName - No filter].Accountant, [SearchByName - No filter].Bank, [SearchByName - No filter].Solicitor, [SearchByName - No filter].Employees, [SearchByName - No filter].[Audit Fee], [SearchByName - No filter].CharityType, [SearchByName - No filter].Sourceoffinancials, [SearchByName - No filter].DateCreated, [SearchByName - No filter].Createby, [SearchByName - No filter].DateModified, [SearchByName - No filter].Modifiedby, [SearchByName - No filter].Prospects.[Key Contact], [SearchByName - No filter].[Address Type], [SearchByName - No filter].Address1, [SearchByName - No filter].Address2, [SearchByName - No filter].Address3, [SearchByName - No filter].Town, [SearchByName - No filter].County, [SearchByName - No filter].Postcode, [SearchByName - No filter].[Telephone Number], [SearchByName - No filter].Email, [SearchByName - No filter].[Incorrect Emails], [SearchByName - No filter].Telemarket, [SearchByName - No filter].Sourceofdata, [SearchByName - No filter].Clientcode, [SearchByName - No filter].DateConverted, [SearchByName - No filter].[Number of Beds in Group], [SearchByName - No filter].[Number of Homes in Group], [SearchByName - No filter].[Healthcare Type], [SearchByName - No filter].CharitiesT, [SearchByName - No filter].WManagementT, [SearchByName - No filter].CareT, [SearchByName - No filter].PropertyT, [SearchByName - No filter].LeisureTourismT, [SearchByName - No filter].MarineT, [SearchByName - No filter].MediaCreativeT, [SearchByName - No filter].ProPracticesT, [SearchByName - No filter].MotorT, [SearchByName - No filter].PersonalTaxT, [SearchByName - No filter].TaxT, [SearchByName - No filter].VATT, [SearchByName - No filter].PayrollT, [SearchByName - No filter].AuditT, [SearchByName - No filter].SAGET, [SearchByName - No filter].AccountsT, [SearchByName - No filter].CFinT, [SearchByName - No filter].BusinessRecoveryT, [SearchByName - No filter].ForensicT, [SearchByName - No filter].GrantT, [SearchByName - No filter].IFAT, [SearchByName - No filter].IntTaxT, [SearchByName - No filter].TaxInvT, [SearchByName - No filter].RenewablesT, [SearchByName - No filter].AcademiesT, [SearchByName - No filter].MTIT, [SearchByName - No filter].NextContactA, [SearchByName - No filter].NextContactNZ, [SearchByName - No filter].KeyContact1NZ, [SearchByName - No filter].KeyContact2NZ, [SearchByName - No filter].DateNZ, [SearchByName - No filter].DateA, [SearchByName - No filter].[Note Full Info], [SearchByName - No filter].[First Name], Subsidiaries.[Holding Company], [SearchByName - No filter].[TPS/CTPS], [SearchByName - No filter].[Top 500], [SearchByName - No filter].NextContact, [SearchByName - No filter].[Payroll Status], [SearchByName - No filter].[Key Contact E-Mail], [SearchByName - No filter].[Key Contacts].[Key Contact], [SearchByName - No filter].[Lead ID], [SearchByName - No filter].Information, [SearchByName - No filter].[Prospect ID], [SearchByName - No filter].Title, [SearchByName - No filter].Date, [SearchByName - No filter].Hyperlink, [SearchByName - No filter].[Added by], [SearchByName - No filter].SortA, [SearchByName - No filter].[Note Information], [SearchByName - No filter].[Filter Checker], [SearchByName - No filter].Group, "Child" AS [Parent / Child], [SearchByName - No filter].[Added by] AS [Note Author], " " AS [Intentionally blank]
FROM Prospects AS Subsidiaries INNER JOIN [SearchByName - No filter] ON Subsidiaries.[Holding Company] = [SearchByName - No filter].ID
WHERE ((("     " & [Subsidiaries]![Company] & " (subsidiary of " & [SearchByName - No Filter]![Company] & ")") Like "*" & [Forms]![Reports]![Search Text] & "*"));

1 ответ

Решение

Поскольку проблема связана с настройкой Access, которая фокусируется на текстовом поле, которое вы не хотите отображать, скрыть это текстовое поле, установив его Visible собственность на No, Access не может установить фокус на скрытое поле.

Другие вопросы по тегам