Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276

    Help Me Fix Text Box To Show Bill No

    I have a form on this form have two combo boxes CmbLox & CmbGPNO and a Text Box txtinvo





    CmbLox - Here I select the location of Plant

    Row Source:

    SELECT Sales.SLocation FROM Sales GROUP BY Sales.SLocation;

    After Update Event:

    Private Sub CmbLox_AfterUpdate()


    Dim strSource As String


    strSource = "SELECT DISTINCT [CCIDCNo] " & _
    "FROM Sales " & _
    "WHERE [SLocation] = '" & Me.CmbLox & "' ORDER BY [CCIDCNo]"


    Me.CmbGPNO.RowSource = strSource
    Me.CmbGPNO = vbNullString




    End Sub



    CmbGPNO - This Shows The Gate Passes Of The Selected Location.

    Row Source:

    SELECT Sales.CCIDCNo, HazBillDetail.BillNo FROM Sales INNER JOIN HazBillDetail ON Sales.CCIDCNo=HazBillDetail.GPNo GROUP BY Sales.CCIDCNo, HazBillDetail.BillNo;


    Note: It is bound to Column 1 & Column Count is 2


    After Update Event:

    Private Sub CmbGPNO_AfterUpdate()


    Me.txtinvo.Value = Me.CmbGPNO.Column(1)


    End Sub



    After selection of Location & Gate Pass The Bill No Should Show In Text Box txtinvo
    Which It is not showing, where am I making a mistake?


    Click image for larger version. 

Name:	form.jpg 
Views:	22 
Size:	52.5 KB 
ID:	42815

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    I'm not sure what difference it might make but I would remove the .Value from:
    Code:
    Me.txtinvo.Value = Me.CmbGPNO.Column(1)
    Use:
    Code:
    Me.txtinvo = Me.CmbGPNO.Column(1)
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Changed Me.txtinvo.Value = Me.CmbGPNO.Column(1) to Me.txtinvo = Me.CmbGPNO.Column(1)
    but no change
    still the text box
    txtinvo is blank and not showing the bill no


  4. #4
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Please do note If I change Me.txtinvo = Me.CmbGPNO.Column(0) then the Gate Pass No Shows in text box txtinvo

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    Can you post a copy of the db.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,411
    You say the rowsource for cmbGPNO is SELECT Sales.CCIDCNo, HazBillDetail.BillNo FROM Sales INNER JOIN HazBillDetail ON Sales.CCIDCNo=HazBillDetail.GPNo GROUP BY Sales.CCIDCNo, HazBillDetail.BillNo;

    But that's replaced by the after_update event of the first combobox cmbLOX with
    "SELECT DISTINCT [CCIDCNo] " & _
    "FROM Sales " & _
    "WHERE [SLocation] = '" & Me.CmbLox & "' ORDER BY [CCIDCNo]"


    So cmbGPNO has only 1 column.

    Try
    this in the after_update event of cmbGPNO

    me.txtinvno=Dlookup("BillNo","HazBillDetail","GPNo =" & me.cmbGPNO)


    Your design is confusing. It would help to see the DB if you wish to upload it here.
    Last edited by davegri; 08-26-2020 at 08:31 AM. Reason: more

  7. #7
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    no it did not work either

    pls give me some time to empty db and then place it here for your analysis

  8. #8
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Hz Ledger 2020.zip Attached is the DB for Analysis

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    Setting the Control Source property of "txtinvo" to:
    Code:
    = CmbGPNO.Column(1)
    would be all that you need if you kept the Row Source of CmbGPNO as it is shown in design mode BUT it gets changed in the After Update event of "CmbLox".

    BTW I have no idea what this db is about but IMHO you tables are in serious need of being normalized. Unless and until that is done I think you will have problems.

    Good luck with your project
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Change this line

    Code:
    Private Sub CmbGPNO_AfterUpdate()
    Me.txtinvo = Me.CmbGPNO.Column(0) 'was 1
    
    End Sub

    All tables should have PKs.
    Field and object names should NOT have embedded spaces NOR special (non alphanumeric) characters.
    good luck.

  11. #11
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    As you said all I have to do is change the source property of txtinvo
    = CmbGPNO.Column(1)

    still it did not work

  12. #12
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Me.txtinvo = Me.CmbGPNO.Column(0)

    even this did not work to show bill no. but it does show gate pass no.
    may be i did not understand it properly

  13. #13
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    Quote Originally Posted by aamer View Post
    As you said all I have to do is change the source property of txtinvo
    = CmbGPNO.Column(1)

    still it did not work
    And if you had bothered to read the rest of my post you may have understood why.

    When the form opens the combo box called "CmbGPNO" has two columns but when you make a selection in the combo called "CobTitl" you change the Row Source property of "CmbGPNO" so that it only has one column but I have no idea why that is done or what data you want to display in the textbox.
    As I said previously, "
    IMHO you tables are in serious need of being normalized. Unless and until that is done I think you will have problems."
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  14. #14
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Further to Bob's comments and advice, perhaps you should give an example showing
    -what should be selected in the combos
    - and what should be the value in the textbox.

    Seems we're guessing incorrectly--- to get explicit answer we need explicit instructions.
    You know the application and we don't.

  15. #15
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    If the Plant Location & DC / Gate Pass is selected the bill no should be as high lighted


    Example:

    Plant Location: Lahore
    DC / Gate Pass #: 11204
    Bill #: 7

    Plant Location: Gujranwala
    DC / Gate Pass #: 12901
    Bill #: 17


    Plant Location: Multan
    DC / Gate Pass #: 11793
    Bill #: 11

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 05-22-2019, 12:25 PM
  2. Replies: 13
    Last Post: 01-21-2018, 08:55 PM
  3. Replies: 5
    Last Post: 02-24-2016, 10:58 PM
  4. Replies: 4
    Last Post: 04-22-2015, 05:46 PM
  5. Replies: 3
    Last Post: 12-22-2012, 05:33 PM

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