Form Display

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

From my main menu, I have a search button to allow a user to find a specific
record. Following is coding, which works fine in bringing up the correct
record, but also brings the main menu form to the front, in front of the form
I am calling. Can someone explain what is going on and how to fix it?

Private Sub cmdFind_Click()
If IsNull([DLCDGrant#]) Then
MsgBox ("You must enter a value in the field.")
ElseIf IsNull(DLookup("[DLCDGrant#]", "tblGrantSum", "[DLCDGrant#] = '" &
[Forms]![frmGrantRecSearch].[DLCDGrant#] & "'")) Then
MsgBox ("Record not Found.")
Else
DoCmd.OpenForm "frmGrantSumDE", , , "[DLCDGrant#] =
[forms]![frmGrantRecSearch].[DLCDGrant#]"
DoCmd.Close acForm, "frmGrantRecSearch"
End If


End Sub

Thanks, Lloyd
 
Hi Lloyd

I suspect that either (a) one of the events fired when the first form closes
is setting focus to the main menu or (b) the first form is modal, so that
control returns to the calling code in the main menu after it closes.

You can probably fix it by adding:
Forms!frmGrantSumDE.SetFocus
after the DoCmd.Close line.
 
You may change the colun inthe first line menu.
Private Sub cmdFind_Click()
If IsNull([DLCDGrant#]) Then
MsgBox ("You must enter a value in the field.")
ElseIf IsNull(DLookup)
("[DLCDGrant#]", "tblGrantSum", "[DLCDGrant#] = '" &
[Forms]![frmGrantRecSearch].[DLCDGrant#] & "'")) Then
MsgBox ("Record not Found.")
Else
DoCmd.OpenForm "frmGrantSumDE", , , "[DLCDGrant#] =
[forms]![frmGrantRecSearch].[DLCDGrant#]"
DoCmd.Close acForm, "frmGrantRecSearch"
End If


End Sub

Thanks, Lloyd


.
 
Back
Top