Results 1 to 6 of 6
  1. #1
    tbassngal is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    27

    RowSource Value not writing to the Table

    Hi all, I have the following sub procedure. The combo box is being filtered as I want it filtered and the control source is Desc1 but cboDesc1.value does not write to the table... cboApplication.value does. Any ideas? Please help.



    Private Sub cboApplication_AfterUpdate()
    Dim sSQL As String

    'Desc1 Value
    'clear cboDesc1
    Me.cboDesc1 = Null

    sSQL = "SELECT Desc1 FROM tblApplicationDescription"
    sSQL = sSQL & " WHERE [Application] = '" & Me.[cboApplication] & "' "
    sSQL = sSQL & " ORDER BY Desc1"

    'Debug.Print sSQL1

    Me.cboDesc1.RowSource = sSQL

    'check if cboDesc1 has values
    If IsNull(Me.cboDesc1.ItemData(0)) Then
    Me.cboDesc1.Enabled = False
    Else
    Me.cboDesc1.Enabled = True
    Me.cboDesc1 = Me.cboDesc1.ItemData(0)

    'optional
    Me.cboDesc1.SetFocus
    Me.cboDesc1.Dropdown
    End If

    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Is the Control Source of cboDesc1 the appropriate field in the table?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    tbassngal is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    27
    Quote Originally Posted by pbaldy View Post
    Is the Control Source of cboDesc1 the appropriate field in the table?
    Yes, the control source of cboDesc1 is Desc1 in the table... I have some events happening that are similar in nature after cboDesc1 has updated, i don't think it could be affecting the value of Desc1 because as I step through the code, cboDesc1 does equal the selection I choose from the drop down from the list filtered by the sSQL. But here is the code that looks near the same for the other two cbo's. FYI: after application is selected, the cboDesc1 is filtered with those values in the table that are associated with application - this is a user field. cboDesc2 & cboDesc3 are just values populated from the same row of data. i have attached the database - and just so you know, I did not create this database, I am only trying to help someone who is just learning but really doesn't care to learn ? Does that make sense? Thank you for your help.

    Private Sub cboDesc1_AfterUpdate()
    Dim sSQL As String

    'cboDesc2 Value
    'clear cboDesc2
    Me.cboDesc2 = Null

    sSQL = "SELECT Desc2 "
    sSQL = sSQL & "FROM tblApplicationDescription "
    sSQL = sSQL & "WHERE(((Application) = '" & Me.cboApplication & "') AND "
    sSQL = sSQL & "((Desc1) = '" & Me.cboDesc1 & "')) "
    sSQL = sSQL & "ORDER BY Application, Desc1"
    'Debug.Print sSQL

    Me.cboDesc2.RowSource = sSQL

    'check if cboDesc2 has values
    If IsNull(Me.cboDesc2.ItemData(0)) Then
    Me.cboDesc2.Enabled = True
    Else
    Me.cboDesc2.Enabled = False
    Me.cboDesc2 = Me.cboDesc2.ItemData(0)
    End If

    'cboDesc3 Value
    'clear cboDesc3
    Me.cboDesc3 = Null

    sSQL = "SELECT Desc3 "
    sSQL = sSQL & "FROM tblApplicationDescription "
    sSQL = sSQL & "WHERE(((Application) = '" & Me.cboApplication & "') AND "
    sSQL = sSQL & "((Desc1) = '" & Me.cboDesc1 & "')) "
    sSQL = sSQL & "ORDER BY Application, Desc1"
    'Debug.Print sSQL

    Me.cboDesc3.RowSource = sSQL

    'check if cboDesc3 has values
    If IsNull(Me.cboDesc3.ItemData(0)) Then
    Me.cboDesc3.Enabled = True
    Else
    Me.cboDesc3.Enabled = False
    Me.cboDesc3 = Me.cboDesc3.ItemData(0)
    End If

    End Sub

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    "Just learning but doesn't care to learn". No, that doesn't make sense. But I know the type.

    I chose Membership Kit in the first combo and KD3319 shows up in the combo. Membership Kit shows in the table in Desc1. That looked odd until I discovered that Desc1 is a lookup field, and it's showing the first field in the table. Personally I won't use lookup fields:

    http://access.mvps.org/access/lookupfields.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    tbassngal is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    27
    Quote Originally Posted by pbaldy View Post
    "Just learning but doesn't care to learn". No, that doesn't make sense. But I know the type.

    I chose Membership Kit in the first combo and KD3319 shows up in the combo. Membership Kit shows in the table in Desc1. That looked odd until I discovered that Desc1 is a lookup field, and it's showing the first field in the table. Personally I won't use lookup fields:

    http://access.mvps.org/access/lookupfields.htm
    Pbaldy! That was exactly the problem! OMG - I kept going over the code again and again! I never thought to look at the formatting of the field in the table. Thank you so much. Again, I didn't set the table up so I had no idea it was set up as a look up field. Problem solved!! Thank you thank you!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problemo!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Writing Query Results to New Table
    By quigongrim in forum Queries
    Replies: 2
    Last Post: 08-23-2010, 09:04 AM
  2. Replies: 2
    Last Post: 06-20-2010, 06:54 PM
  3. Writing data from textbox to table
    By mll in forum Forms
    Replies: 4
    Last Post: 03-10-2010, 05:10 PM
  4. Replies: 0
    Last Post: 08-26-2009, 11:51 AM
  5. Automatically Writing SQL From A Table
    By smitstev in forum Programming
    Replies: 1
    Last Post: 06-05-2009, 09:38 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