Dlookup kills database

  • Thread starter Jay974 via AccessMonster.com
  • Start date
J

Jay974 via AccessMonster.com

Hi All

I have a form which is used to manage customer contacts within our
organisation. Part of the form is multi-tabbed to allow users to separate
contact notes from different departments i.e. one tab for our sales
department notes, one for our accounts department, etc.

When the user enters the customer's account number, the tabs display the
relevant contact information. This is done with a list box on each tab
displaying the note date, the note subject and the who left the note. when
the user clicks on the list box, the note text is displayed in a text box
underneath using a dlookup. The dlookup is set on the tab change event.

Initially, this worked fine however when we added another tab on the form for
a new department, the database closes when it gets to the dlookup for the new
tab. The code is very similar and i am at a loss to explain why this is. Can
anyone help?

Here is the code which workes successfully on one of the other tabs

If Me.txtInvestigationNote.Tag = "unset" Then

Me.lstInvestigationNotes.Requery

Me.lstInvestigationNotes.SetFocus

If Me.lstInvestigationNotes.ListCount <> 0 Then

Me.lstInvestigationNotes.ListIndex = 0

Me.lstInvestigationNotes.Selected(0) = True

Me.txtInvestigationNote.ControlSource = "=DLookup(""[notetext]"",
""tblNote"", ""[id] = "" & Forms![frmMain]![lstInvestigationNotes])"

End If

Me.txtInvestigationNote.Tag = "set"

End If

This is the code for the tab which kills the database when the dlookup is
fired

If Me.txtAccOpeningNote.Tag = "unset" Then

Me.lstAccOpeningNotes.Requery

Me.lstAccOpeningNotes.SetFocus

If Me.lstAccOpeningNotes.ListCount <> 0 Then

Me.lstAccOpeningNotes.ListIndex = 0

Me.lstAccOpeningNotes.Selected(0) = True

Me.lstAccOpeningNotes.ControlSource = "=DLookup(""[notetext]"",
""tblNote"", ""[id] = "" & Forms![frmMain]![lstAccOpeningNotes])"

End If

Me.txtAccOpeningNote.Tag = "set"

End If
 

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