Results 1 to 13 of 13
  1. #1
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276

    Combo Update Field Not Updating Also Combo Does Not Show Value Of Column 2

    I am having 2 problems with the attached sample cash bookthat I am working on. It does not show the ID Card No. When I Select the LabourDaily Wages in the Account Head and Then Name of The Worker in Description,where as the rest of the descriptions are updated.

    The combo “Perticulars” does not show the value of column2, and after update it does not update the value of column 2 in the field “DBKNic”.

    Combo Box “A/C Head”

    SELECT [DBKHeads&Items].[DBKHHead] FROM[DBKHeads&Items] GROUP BY [DBKHeads&Items].[DBKHHead];

    Combo Box “Perticulars”

    SELECT [DBKHeads&Items].DBKHItems,[DBKHeads&Items].DBKHNICNo FROM [DBKHeads&Items] WHERE((([DBKHeads&Items].DBKHHead)=[forms]![DBKCashBook].[A/C Head])) GROUP BY[DBKHeads&Items].DBKHItems, [DBKHeads&Items].DBKHNICNo;


    After update properties of “Perticulars”

    Private Sub Perticulars_AfterUpdate()
    Me.DBItmDesc = Me.Perticulars.Column(0)
    Me.DBKNic = Me.Perticulars.Column(1)


    Me.Refresh
    End Sub

    I could not locate the mistake am doing, a help in fixingthis problem would be highly appreciated.

    A sample is attached.



    Sample.zip


  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    The code you have posted above does not match the code you are actually using - correct the code in your form and see if that solves the problem.

    Some tips

    avoid using &, / spaces and other non numeric characters in your table, field and control names
    include Option Explicit at the top of each module (just below Option Compare Database)
    give your controls relevant names relating to the field (e.g. prefix field name with txt) - will make debugging a lot easier

  3. #3
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    I have checked and re-checked with the code of Sample posted.
    I could not find any difference with the code I have posted.

  4. #4
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    your code says

    Code:
    Private Sub A_C_Head_AfterUpdate()
     Dim strSource     As String
      strSource = "SELECT DBKHItems " & _
                  "FROM [DBKHeads&Items] " & _
                  "WHERE DBKHHead = '" & Me.[A/C Head] & "' ORDER BY DBKHItems"
      Me.Perticulars.RowSource = strSource
      Me.Perticulars = vbNullString
    End Sub
    your thread says

    Combo Box “Perticulars”

    SELECT [DBKHeads&Items].DBKHItems,[DBKHeads&Items].DBKHNICNo FROM [DBKHeads&Items] WHERE((([DBKHeads&Items].DBKHHead)=[forms]![DBKCashBook].[A/C Head])) GROUP BY[DBKHeads&Items].DBKHItems, [DBKHeads&Items].DBKHNICNo;

  5. #5
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    My Bad. I copied & posted the row source of the fields.

  6. #6
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Quote Originally Posted by Ajax View Post
    The code you have posted above does not match the code you are actually using - correct the code in your form and see if that solves the problem.

    Some tips

    avoid using &, / spaces and other non numeric characters in your table, field and control names
    include Option Explicit at the top of each module (just below Option Compare Database)
    give your controls relevant names relating to the field (e.g. prefix field name with txt) - will make debugging a lot easier


    I did all you explained but still its not working.

    I have added a new sample.

    New Sample.zip

  7. #7
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    please excuse me for jumping in but i'm confused on what you are after. you stated you were having two problems, first " It does not show the ID Card No. When I Select the LabourDaily Wages in the Account Head ", there's no records in your table to display. second "Then Name of The Worker in Description,where as the rest of the descriptions are updated", if you are referring to the second column of ACHEAD not populating the second column of Perticulars it doesn't have anything to do with your code. in your query for perticulars you are displaying 3 columns but in your combo properties only 2. changed column count to 3 and added a zero for the third column width and it worked. sometimes its the easy things right in front of you that is the problem and hardest to see. been there.

  8. #8
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    vicsaccess



    Thank u for jumping in

    you are absolutely right sometimes things are right in front of you but you cant see them, I guess this is the case with me.

    As you said I should change the column count to 3 and column width to 1",1", 0" that I did. But Still I cannot see The DBKHNICNo when I select "Labour Daily Wages" in ACCOUNT HEAD and "Ahmed Rabani" in Description It does not Show the DBKHNICNo "795321785"

    I have attached the New Sample 1 after making changes as advised by you.

    New Sample 1.zip

  9. #9
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    keep it simple, code is nice but understand it first. simpler more efficient way is-
    in the query row source for Perticulars change the criteria to "[Forms]![DBKCashBook]![ACHead]"
    comment out the afterupdate event and create a new event for onchange, add-
    Code:
        Me.Perticulars = Null
        Me.Perticulars.Requery

  10. #10
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    vicsaccess

    Thank you for your help & pointing me in right direction

    Please check the New Sample 2, If I have corrected as you have explained.

    New Sample 2.zip

  11. #11
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    looks good, working for you?

  12. #12
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Yes its working great
    Thx again for your help.

  13. #13
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    No problem, please reread Ajax original post with the tips. The tips these experts give us are out of experiance from doing it the wrong way and having to fix it later

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

Similar Threads

  1. Replies: 1
    Last Post: 02-24-2015, 06:54 PM
  2. Replies: 4
    Last Post: 08-09-2014, 02:33 PM
  3. Replies: 1
    Last Post: 05-03-2012, 04:59 AM
  4. Replies: 4
    Last Post: 11-24-2011, 10:26 PM
  5. Replies: 5
    Last Post: 07-01-2011, 11:13 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