Results 1 to 14 of 14
  1. #1
    Join Date
    May 2012
    Posts
    89

    Unanswered: textbox form1 - textbox form2

    Hi can someone tell me how i get the value in a textbox in lets say form1 to a autofill in a textbox form2...
    Hope someone can tell me cause its bumming me out...

  2. #2
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    In the After Update event of the text box (txtSource) in form1 put something like this:

    Forms![Form2].[txtDestination].value = txtSource.value

    However, this will only work if form2 is open so you'll have to do some error checking

    Steve

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    You don't say how you plan on doing this 'autofill,' but the code for assigning one to the other would be

    Forms(Form2)!F2ControlName = Me.F1ControlName

    or

    Forms!Form2!Form2ControlName = Me.F1ControlName

    Form2 has to be Open, of course, and on the appropriate Record.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    May 2012
    Posts
    89
    Quote Originally Posted by sps View Post
    In the After Update event of the text box (txtSource) in form1 put something like this:

    Forms![Form2].[txtDestination].value = txtSource.value

    However, this will only work if form2 is open so you'll have to do some error checking
    Hi Steve thanks for replying...

    If tried your code bud i get a error 2456 (Can't find form "form2")
    If checked for typo's and its all ok...
    If started the code (form on open)

  5. #5
    Join Date
    May 2012
    Posts
    89
    Quote Originally Posted by Missinglinq View Post
    You don't say how you plan on doing this 'autofill,' but the code for assigning one to the other would be

    Forms(Form2)!F2ControlName = Me.F1ControlName

    or

    Forms!Form2!Form2ControlName = Me.F1ControlName

    Form2 has to be Open, of course, and on the appropriate Record.

    Linq ;0)>
    The planning was the first thing i was running into i dint know where to start bud to explain what im doing:
    If got an loginform with a PWD after logging in there can be records added bud we want to know who has put the info/records in (formerly we used exel and wrote an name after all the records...) and sins the name is already in an text box of an other form, i wanted to use this textbox,
    Maybe you have an other idea on how to get this done...

    PS.
    If tried both your codes:
    With the: Forms(Form2)!F2ControlName = Me.F1ControlName :I get a error 2456 (Can't find form "form2")
    With the: Forms!Form2!Form2ControlName = Me.F1ControlName :I get an syntax error, even though i dont get the F1 and F2's in the code.
    Last edited by Rubberducksucker; 07-02-12 at 16:17.

  6. #6
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    The name "Form2" was taken from your original post, you have to change Form2 to the actual name of your second form. Do the same thing for the text fields. Everything in red needs to be changed to match the actual names in your database.

    Forms![Form2].[txtDestination].value = txtSource.value

    Steve

  7. #7
    Join Date
    May 2012
    Posts
    89
    Quote Originally Posted by sps View Post
    The name "Form2" was taken from your original post, you have to change Form2 to the actual name of your second form. Do the same thing for the text fields. Everything in red needs to be changed to match the actual names in your database.

    Forms![Form2].[txtDestination].value = txtSource.value
    No it doesn't work i am kinda giving op on it...
    Bud thanks for trying...

  8. #8
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    Could you post the code that you are using along with the names of your forms? It's probably something small that's making a big difference.

    Steve

  9. #9
    Join Date
    May 2012
    Posts
    89

    Smile

    Okay...

    The form where the data is from is called: frmInlog
    The txtbox where the data is from is called: qUSERID

    The form where the data need to go is called: frmHOOFD
    The txtbox where the data is from is called: qUSERID

    The code that i got from u i used and it looks like:


    Private Sub qUSERID_AfterUpdate()
    Forms![frmHOOFD].[qUSERID].value = qUSERID.value


    ^This 1 is on the form frmInlog.^
    --------------------------------------------------
    Private Sub qUSERID_AfterUpdate()
    Forms![frmInlog].[qUSERID].value = qUSERID.value


    ^This 1 is on the form frmHOOFD.^

    Thanks for the help

  10. #10
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    How is qUSERID being populated on frmInlog? It has to be populated physically, which is to say by having it manually entered thru the keyboard or it has to be Pasted into qUSERID in order for the AfterUpdate event to execute.

    Not sure what you're trying to do with your second code example, since your statement is that you're populating the Field in the frmHOOFD Form, not in the frmInlog Form. It wouldn't fire, anyway, as it is not being populated physically.

    What version of Access are you running? In 2007/2010 code will not run unless the Folder holding the file has been declared as 'Trusted.' Does any code run?

    And once again, as Steve and I have both said, the second Form, frmHOOFD, has to be open and on the appropriate Record at the time of the assignment.

    Linq ;0)>
    Last edited by Missinglinq; 07-04-12 at 20:58.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    Join Date
    May 2012
    Posts
    89
    I am using Acces version 2003,
    The qUSERID on frmInlog is indeed physically populated because it as a login form, after the login name qUSERID and the password qPWD has been completed the login button the form frmHOOFD opens...
    Moreover if tried to enter the value in qUSERID and qPWD to enter while the frmHOOFD is already open but then the textbox qUSERID on frmHOOFD stays empty...
    And the textbox qUSERID on frmHOOFD and qUSERID on frmInlog are both Unbound... may that be the problem

  12. #12
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    I'm not entirely clear on that last explanation of yours, but I'll try...

    If frmInLog is your login form, start there. Does it have a login button? If so, use the on click routine and enter the code there:

    Forms![frmHOOFD].[qUSERID].value = qUSERID.value

    If it doesn't have a button how are you currently catching the user entry to proceed with the rest of the system? Add the code to that section.

    You could also try naming the userID field differently in frmHOOFD and frmInLog just to make it clearer to you what value is being used and which one is being set.

    Also, remember that frmHOOFD has to be open before you try to process the value from frmInLog. It doesn't have to be visible, but it does have to be open. So, if this is your startup form you would need to have a doCmd.OpenForm call to open frmHOOFD in the load routines of frmInLog. (There are a few events that are triggered when a form is loaded. Look at this link for some information on the order of them: Load Event [Access 2003 VBA Language Reference])

    As ling said, you don't need this code:
    Forms![frmInlog].[qUSERID].value = qUSERID.value
    This is trying to set the value on the login form with this value and that's opposite of what you need. Besides, the value in qUSERID is read only so it won't change.

    Steve

  13. #13
    Join Date
    May 2012
    Posts
    89

    Thumbs up

    Hi made some chances:
    If got different names for the textboxes instead of both (qUSERID)
    And i got the form (frmHOOFD) to open along with the form (frmLogin) where the value is entered...
    It works like a charm....

    Thanks for the help guys!

    But now i have 1 question:
    When someone opens the database they have to login in the (frmLogin) form but the database is already open in an other field but minimized in the taskbar below on the screen if they find out that they can click on the (fmrHOOFD) in the Taskbar they click on that without login with the problem that i dont know who has entered the records... this could cause problems for my and i hope there is an option that will disable the taskbar to use as an button to maximize the (frmHOOFD) until there has been an login....

  14. #14
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    Does frmLogin open when the database is started? Just set the Modal property on frmLogin to true. This will force the user to close this form before they can do anything else. You can do things to make it more difficult to get around your form but most things can be circumvented anyway.

    As long as you trust your users to be honest then just set frmLogin as the Startup form and set the Modal property toTrue so they have to close it before going anywhere else. You can also make frmHOOFD hidden until you are satisfied with their responses.

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •