Results 1 to 7 of 7
  1. #1
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169

    Add Record Button isn't working

    I have a form that has combined comboboxes and textboxes. I used the combobox and coding to pre-populate the textboxes with the information. I used the wizard in Access 2000 to create an add record button that is to add what is on the screen to the table that is created but is blank but does have the columns already created. I am wondering if because the textboxes are bound to the combobox is this is why I am having the problem. I have attached the form picture so you can see but I can tell you for instance my userfirstname text is set to =userlastname.column(2) etc etc etc for everything I have. And then the query itself in the combobox has all the items I need. So I think the reason I am having issues might be that the other columns are bound now and combos are unbound.

    Here is my add record code:
    Private Sub Add_Record_Click()
    On Error GoTo Err_Add_Record_Click


    DoCmd.GoToRecord , , acNewRec

    Exit_Add_Record_Click:
    Exit Sub

    Err_Add_Record_Click:
    MsgBox Err.Description


    Resume Exit_Add_Record_Click


  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    an approach that will work is to do this:

    1. change from an unbound form to a form bound on the table you wish to populate (make the table it's record source)

    2. move all the vb code (i.e. =userlastname.column(2)) out of those textboxes - because they need to be bound to the underlying record source table; and instead put them in the AfterUpdate Event of the comboboxes i.e.
    me.userfirstnametext = me.userlastname.column(2)

    actually do item 2 before item 1.

    hope this helps.

  3. #3
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169

    It didn't work

    Now my text boxes don't prefill.

    I have:

    private sub userlastname_afterupdate()
    me.userid = me.userlastname.column(1)
    me.userfirstname = me.userlastname.column(2)

    end sub

    so I tried:

    private sub userlastname_afterupdate()
    me.useridtext = me.userlastname.column(1)

    etc etc etc and then ended it with

    end sub

    neither way worked.
    I will try doing it like this and see if that works

    me.[tri_adv].[userid] = me.[tri_adv].[userlastname].[column](1)

    and see if it gives me an error or what.

  4. #4
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169

    that didn't work

    well that didn't work either

  5. #5
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169

    nothing is working that I have tried

    I think because I am using access 2000 and this forum is everything related to access 2007 it looks like. I am losing my mind with this. does anyone out there know what the heck is going on with why i can't get this to work?

  6. #6
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    this advice is uniform for all versions of Access.

    presuming no subforms are involved; and that userlastname is indeed a combobox....

  7. #7
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169

    Finally

    It is finally working. I had to play around with the me.userlastname coding stuff. I just kept trying different things til it worked. it was erroring out when it ran at me.managerlastname = me.userlastname.column(6)

    The column choice was right and it said managerlastname but I noticed when typing the acutal code it kept changing to managerlast only. That was the only choice. So I said well that is not right. Text box isn't named that. Nor is label nor is the database column. It is managerlastname. But for some reason it was only seeing managerlast. Oh you know what, I didn't chk the length in the table. Maybe that is why it is only taking managerlast. Or maybe some length thing in the form. Will have to look. but using me.managerlast = me.userlastname.column(6) works and it all works now and autopopulates and adds record and does everything. thank you everyone. I will never forget this little tidbit of coding.

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

Similar Threads

  1. New record button
    By smikkelsen in forum Forms
    Replies: 8
    Last Post: 03-31-2010, 11:16 PM
  2. Add new record button
    By smikkelsen in forum Access
    Replies: 0
    Last Post: 03-29-2010, 02:55 PM
  3. Replies: 6
    Last Post: 02-09-2010, 07:53 AM
  4. Replies: 4
    Last Post: 05-12-2009, 01:50 PM
  5. Find Record button error
    By Zedlexx in forum Forms
    Replies: 0
    Last Post: 03-11-2009, 09:26 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