Results 1 to 9 of 9
  1. #1
    acunin.rommel is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2017
    Posts
    5

    Pass the value from combobox to text box between forms


    Greetings!

    I am newbie in Ms Access 2010. I have a two form "frmResearch" and "frmAuthor" they are link together by ID. The frmResearch contains the information about the authors research project. and the frmAuthor contains the information about the author. These two forms already populated with some data. I created a combobox, "cboSelectAuthor" in frmResearch and already populated with authors. I created a textbox "txtAuthorFullName" and a command button cmdNewAuthor for new author. The "frmAuthor will pop up once cmdNewAuthor was clicked to enter new Author. With Author_FirstName and Author_LastName Here is my inquiry:

    1. How to pass the value from the cboSelectAuthor to txtAuthorFullName in add new data mode?
    2. How to pass the value of the new author from frmAuthor to the txtAuthorFullName in the frmResearch concatenating Author_FirstName and Author_LastName.

    Hope someone will have a time to look at it.

    Thanks in advance.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    open new form
    set form value

    docmd.openform "frm2"
    forms!frm2!txtBox = forms!form1!txtbox

  3. #3
    acunin.rommel is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2017
    Posts
    5
    Quote Originally Posted by ranman256 View Post
    open new form
    set form value

    docmd.openform "frm2"
    forms!frm2!txtBox = forms!form1!txtbox
    Sorry I'm a little bit confused.
    I already have data in my textbox and it has a control group. When the user add a new data in frmResearch. The user will select in the Authorcombobox. And will pass the value to the authortxtbox (not unbound, with control group)
    If the Authors name couldnot find in the list. Will click the new Author(command button) and will pop up the form 2 "frmAuthor. To type the first name and last name of the author and will click OK. After clicking OK button. It will concatenate firstname and lastname and will pass the vale to the authortxtbox.

    Please let me know if explain it clear.

    Thanks,

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The general way this occurs is that the Add New button will be clicked first, before any entry is made in the first form. Set your combobox property Limit to List = Yes, then if they can't find the author they click on the Add New button. This opens a form which must have the Modal property set to Yes where a new author is entered. In the OnClose event of that form, add an Event Procedure to (1) requery the combobox of authors so that the new one is added to the list and (2) update the fields on the first form in the same way that you do it already.

  5. #5
    acunin.rommel is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2017
    Posts
    5
    Hello Aytee111!

    Would you mind to provide me a VBA code?

    Thanks,

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    To do what?

  7. #7
    acunin.rommel is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2017
    Posts
    5
    Okay..let me explain, If in the user could not find the AuthorName in the combobox. The user will click the AddAuthor button and when the user entered FirstName and LastName on form2, the result should be concatenated to FullName which will be added in the txtFullName in form1. Hope you can provide me with the VBA and would be much appreciated if you can explain it step by step. I just want to ask also if the txtFullname (Form1) should be "unbound" as I tied it in the query. And I get an error in the VBA that it says "cannot run the code due to the destination has an expression".

    Sorry for being dumb about this but I am keen to move forward on this, looking forward for your reply.

    Once again thank you for your help.

  8. #8
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The AddAuthor button, OnClick event, open form2 with OnLoad DoCmd.GoToRecord,,acNewRec. This opens the second form to a blank screen where the user enters the new author information.

    OnClose event of this form (it has Modal property set to Yes):
    Forms!form1lastname!lastname=Me!lastname
    Forms!form1firstname=Me!firstname

    It is easier to keep the names separate on form1, but it you want to put them together do the same as in your query, e.g. Forms!form1name!fullname=Me!firstname & " " & me!lastname

  9. #9
    acunin.rommel is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2017
    Posts
    5
    Thanks aytee, I will try and get back to you..

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

Similar Threads

  1. Replies: 6
    Last Post: 11-14-2014, 12:27 PM
  2. Two Forms One Combobox
    By rhubarb in forum Forms
    Replies: 4
    Last Post: 06-13-2014, 12:26 PM
  3. Replies: 2
    Last Post: 06-25-2012, 09:24 AM
  4. Replies: 5
    Last Post: 04-19-2012, 09:35 AM
  5. Pass variable name to another forms
    By Thomman in forum Access
    Replies: 3
    Last Post: 04-07-2011, 10:01 AM

Tags for this Thread

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