I have a form with an invisible subform that is used for entering search criteria. When the user clicks the "Enter Selection Criteris" button, the form is made visible. After there criteria is entered, the user has the choice of three buttons, "Select Records", "No Selection" (turns off filter, but leaves entries in place) and "Clear" (turns off filter and clears criteria fields)
The code for each of these buttons is:
Select records:
Private Sub EnterCmd_Click()
Dim retst as String
dim tststr as String
Me.EnterCmd.SetFocus
retst = ""
retst = FormatProcessParms(1)
If retst <> "I Open" Then
If retst <> ""
filterString = retst
FocusToTitle = 1
Else
FilterString = "Title LIKE '*'"
FocusToTitle = 1
End If
Forms!Books!FocusTgt.SetFocus
End If
End Sub
Note: FormatProcessParms function processes the values in the criteria selection fields and returns a filter string.
No Selection:
PrivateSub NoSelect_Click()
FocusToTitle = 2
Forms!Books!FocusTgt.SetFocus
End Sub
Clear:
Private Sub Clear_Click()
FormatProcessParms (2)
FocusToTitle = 3
Forms!Books!FocusTgt.SetFocus
End Sub
The FocusToTitle is a global variable that tells the Focus Target on the main form (an invisible unbound text box that only server as a target to receive the focus) which button was pushed.
FocusTgt:
Private Sub FocusTgt_GotFocus()
Select Case FocusToTitle
Case 1
Me.Filter = FilterString
Me.FilterOn = True
Case 2
Me.FilterOn = False
Case 3
FilterString = ""
Me.FilterOn = False
End Select
Me.CriteriaInput.Visible = False
FocusToTitle = 0
End Sub
My problem is this. When the main form is looking at the first record and criteria is entered and the Select Records button is pushed, all is well. If the main form is elsewhere, I get a message box telling me I can't set the focus to that target. It has an OK button.
If either of the other two buttons is pushed, I get a message box that says the same thing, but now there are Continue (grayed out), End, Debug, and Help buttons.
If I push the OK button, the focus goes exactly where it was told to go, to the FocusTgt text box. If the End button is pressed, the focus goes to the Title text box, which has the tab index of 1. (The FocusTgt text box is tab index 0 but tab stop is NO).
The proper selections are being made and the text box with the OK is must a major annoyance. However, the message box with the four buttons is a disaster waiting for the day that the user hits the Debug button.
I have played with SetWarnings and it doesn't seem to help.
Does anyone have any idea why this could be hapening?
The code for each of these buttons is:
Select records:
Private Sub EnterCmd_Click()
Dim retst as String
dim tststr as String
Me.EnterCmd.SetFocus
retst = ""
retst = FormatProcessParms(1)
If retst <> "I Open" Then
If retst <> ""
filterString = retst
FocusToTitle = 1
Else
FilterString = "Title LIKE '*'"
FocusToTitle = 1
End If
Forms!Books!FocusTgt.SetFocus
End If
End Sub
Note: FormatProcessParms function processes the values in the criteria selection fields and returns a filter string.
No Selection:
PrivateSub NoSelect_Click()
FocusToTitle = 2
Forms!Books!FocusTgt.SetFocus
End Sub
Clear:
Private Sub Clear_Click()
FormatProcessParms (2)
FocusToTitle = 3
Forms!Books!FocusTgt.SetFocus
End Sub
The FocusToTitle is a global variable that tells the Focus Target on the main form (an invisible unbound text box that only server as a target to receive the focus) which button was pushed.
FocusTgt:
Private Sub FocusTgt_GotFocus()
Select Case FocusToTitle
Case 1
Me.Filter = FilterString
Me.FilterOn = True
Case 2
Me.FilterOn = False
Case 3
FilterString = ""
Me.FilterOn = False
End Select
Me.CriteriaInput.Visible = False
FocusToTitle = 0
End Sub
My problem is this. When the main form is looking at the first record and criteria is entered and the Select Records button is pushed, all is well. If the main form is elsewhere, I get a message box telling me I can't set the focus to that target. It has an OK button.
If either of the other two buttons is pushed, I get a message box that says the same thing, but now there are Continue (grayed out), End, Debug, and Help buttons.
If I push the OK button, the focus goes exactly where it was told to go, to the FocusTgt text box. If the End button is pressed, the focus goes to the Title text box, which has the tab index of 1. (The FocusTgt text box is tab index 0 but tab stop is NO).
The proper selections are being made and the text box with the OK is must a major annoyance. However, the message box with the four buttons is a disaster waiting for the day that the user hits the Debug button.
I have played with SetWarnings and it doesn't seem to help.
Does anyone have any idea why this could be hapening?