Form Display

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
 
G

Graham Mandeno

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.
 
C

Cheah Chin Thai

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


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top