Sub Form showing same product description for different products

XV1957

Registered User.
Local time
Today, 23:42
Joined
Aug 6, 2014
Messages
80
Hi,
I have a Purchase Order Subform which contains the Order lines listing the different articles.
I would like the Subform to display each article’s description.
I have the following code in the on current event of the subform (copied from one of the Northwind examples) and on the after update event of the Article Number .
The problem: If for example I have 4 different articles, it shows the same description for each of the 4 articles, instead of showing each article’s own description.
How can I force each line to show its own Article description?

Private Sub Form_Current()
Dim strFilter As String

strFilter = "Artno = '" & Me!PuLineArtno & "'"

Me.txtDescr = DLookup("Desc", "tblArticle", strFilter)
End Sub

Private Sub PuLineArtno_AfterUpdate()
Dim strFilter As String

strFilter = "Artno = '" & Me!PuLineArtno & "'"

Me.txtDescr = DLookup("Desc", "tblArticle", strFilter)
End Sub

Thanks in advance.
 
Hi Uncle Gizmo,
I cannot see why this is happening.
Indeed all article lines are separate records, tied through a common field to the main order header form and table.
This is a continuous form constructed to look like a datasheet.

I noticed that when I changed this sub form to Datasheet, it displayed the article descriptions correctly, however one by one on a form.

Maybe the attachments will give you the clue, I am certainly not seeing them.
Thanks a lot for your help.
 

Attachments

  • Continuous form as a datasheet.JPG
    Continuous form as a datasheet.JPG
    40.1 KB · Views: 106
  • Datasource.JPG
    Datasource.JPG
    29 KB · Views: 97
  • Format.JPG
    Format.JPG
    59.2 KB · Views: 100
The problem: If for example I have 4 different articles, it shows the same description for each of the 4 articles, instead of showing each article’s own description.
How can I force each line to show its own Article description?
This happens because the control for the description is unbound!
 
Hi JHB,
Thank you for your reply.

Should the DLookup function be written in the recordsource? How would I have to write it?
 
I tried putting the DLookup in the record source and keep getting error messages.
The syntax, which I ended up coying en adapting from forums is:
=DLookUp("Desc", "tbArticle", "Artno = " & forms![frmPuLines]![PuLineArtno])
What is wrong with it?
 
Solved!
I used the expression builder and of course put in a test for strings
=DLookUp("[Desc]";"tblArticle";"Artno='" & [Forms]![frmPuLines]![PuLineArtno] & "'")
Thanks Uncle Gizmo and JHB for leading the way.
 

Users who are viewing this thread

Back
Top Bottom