Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2017
    Posts
    1

    Getting a specified Client Name on Report

    Hi All, its my first post on this forum. Please excuse if my question is not properly described.


    I have a report "Freight Invoice Client". The report is OK at the moment no errors. But my user needs some thing more on this report.
    A Dialog Form "Dialog Freight Invoice Selective Consignment-Client" opens the report. The form has two Un bound Combo boxes:
    "cmbConsignmentNo"-->Row Source
    SELECT DISTINCT CollectionVoucher.ConsignmentNo


    FROM CollectionVoucher
    ORDER BY CollectionVoucher.ConsignmentNo DESC;
    Having After Update Event:
    Private Sub cmbConsignmentNo_AfterUpdate()
    Me.cmbClientCIN.RowSource = "SELECT DISTINCT Clients.ClientCIN, Clients.ClientName, Consignee.ConsigneeName " & _
    "FROM Consignee INNER JOIN (Clients INNER JOIN CollectionVoucher " & _
    "ON Clients.ClientCIN = CollectionVoucher.ClientCIN) " & _
    "ON Consignee.ConsigneeName = Clients.CosigneeName " & _
    "WHERE CollectionVoucher.ConsignmentNo = '" & Nz(Me.cmbConsignmentNo, "") & _
    "' ORDER BY Clients.ClientCIN"
    End Sub
    Second un bound Combo box "cmbClientCIN"----> Row Source:
    SELECT DISTINCT Clients.ClientCIN, Clients.ClientName
    FROM Clients
    ORDER BY Clients.ClientCIN;
    The Report shows "ClientName" on its Report Header in Text box "CINandName" with Control Source:
    ="CIN: " & [ClientCIN] & ", Consignor: " & [ClientName] & ", Consignee: " & [CosigneeName]
    My user needs that in data entry on Form "New Cargo Collection Input" for a particular "ConsignmentNo" what "ClientCIN" is selected, its "ClientName" should dispay on the report for specific "ConsignmentNo" even after wards "ClientName" is edited OR changed for specific "ClientCIN". My answer was simpy add new Client, but he has reservations for adding more and more Cients for some practical work reasons,while collecting cargo by his staff.
    The only solution which i thought was to add a new field "NameOfClient" in table "CollectionVoucher" and on Before update event of Sub form "NewCargoCollectionInputsubform" add a line:
    Me.NameOfClient = Me.ClientSelected
    It did worked and NameOfClient does saves in table.
    Secondly changing in reports Text box "CINandName" Control Source.
    ="CIN: " & [ClientCIN] & ", Consignor: " & [ClientName] & ", Consignee: " & [CosigneeName]
    To:
    ="CIN: " & [ClientCIN] & ", Consignor: " & [NameOfClient] & ", Consignee: " & [CosigneeName]
    Now the in Dialog Form "Dialog Freight Invoice Selective Consignment-Client" After Update Event of "cmbConsignmentNo" must be changed to get "NameofClient" from table "CollectionVoucher" which i am unable to set.
    This is my approach. If some other better solution or possibilty is there please help and guide.
    Regards,
    Khalid


  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,474
    Holy WALL of TEXT Batman!!!

    Maybe give some data examples of what you have on the form, in the tables/reports and what you need changed or added. Also might be good to attach a copy of the database so the fine folks on here can help troubleshoot.

  3. #3
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Yeah, that's a lot of strain on the eyes. Please use code tags and indentation/separation.
    If all you want to do is pass one value from a form to any other form or report when it's opened, use the OpenArgs parameter of the DoCmd.OpenForm method. When the form/report opens, pass the argument to the control.
    https://msdn.microsoft.com/en-us/vba...roperty-access
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    What is the SQL for the Report?
    Why can't you just add "NameofClient" to the report record source???

    Then edit the "CINandName" control on the report.



    ----------------------------------------------------------------
    I am not a fan of the way your cascading combo boxes are are set up.

    If you try this, do so on a COPY of your dB...... (just in case --- you have been warned!)

    Unbound "cmbConsignmentNo"-->Row Source
    Code:
    SELECT DISTINCT CollectionVoucher.ConsignmentNo
    FROM CollectionVoucher
    ORDER BY CollectionVoucher.ConsignmentNo DESC;
    Having After Update Event:
    Code:
    Private Sub cmbConsignmentNo_AfterUpdate()
       Me.cmbClientCIN = vbnullstring
       Me.cmbClientCIN.Requery 
    End Sub

    Unbound "cmbClientCIN"----> Row Source:
    Code:
    SELECT DISTINCT Clients.ClientCIN, Clients.ClientName, Consignee.ConsigneeName, CollectionVoucher.NameofClient 
    FROM Consignee INNER JOIN (Clients INNER JOIN CollectionVoucher 
    ON Clients.ClientCIN = CollectionVoucher.ClientCIN) 
    ON Consignee.ConsigneeName = Clients.CosigneeName 
    WHERE CollectionVoucher.ConsignmentNo = '" & Nz(Me.cmbConsignmentNo, "")
     ORDER BY Clients.ClientCIN

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Opening a monthly report from Client form
    By redekopp in forum Programming
    Replies: 11
    Last Post: 02-03-2016, 11:32 AM
  2. Replies: 3
    Last Post: 11-25-2014, 01:14 PM
  3. Replies: 3
    Last Post: 10-30-2012, 12:28 PM
  4. Missing client details report
    By crxftw in forum Reports
    Replies: 3
    Last Post: 08-16-2011, 12:19 PM
  5. Replies: 1
    Last Post: 07-26-2011, 06:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums