Modifying RecordSource of another form

  • Thread starter George Stevenson
  • Start date
G

George Stevenson

I've got 2 forms. The first is my search form which has a control to enter
a lastname to be queried from my DB.

Form 2 is frmSubTrustee, the form I want to display with a record source
built with a SQL command. Here is the Click code when I submit the last
name. It goes wacky when I try to set the RecordSource. StrName is the
control on my Search form that contains the Last Name value. GES is the
name of my table that I'm searching.
Can anyone point out what looks wrong. Somehow is doesnt seem to find the
Form name frmSubTrustee.

Private Sub cmdName_Click()
On Error GoTo Err_cmdName_Click
If IsNull(Trim(strName.Value)) = False Then
mySQL = "SELECT GES.* FROM GES " & _
"WHERE InStr(1, GES!OwnerName, [Me!strName.Value]) > 0 ORDER
BY ges.dtadded DESC;"
DoCmd.OpenForm "frmSubTrustee", acNormal, , , acFormEdit, acHide
Forms!frmSubTrustee.RecordSource = mySQL
End If

Exit_cmdName_Click:
Exit Sub

Err_cmdName_Click:
MsgBox Err.Description
Resume Exit_cmdName_Click
 

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