• Carrying text feilds across forms (2k)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Carrying text feilds across forms (2k)

    Author
    Topic
    #407801

    I have a main form where one of the text fields is ‘Title’. When you click on one of the buttons, a check list form opens up where once again, one of the text fields is ‘Title’, which is the same title from the previous form. However this checklist form does not contain every entry from the main form, it creates entries per main form item as required. What i want to do is carry over the ‘Title’ field from the main form to the checklist form so users don’t have to enter repetitive data, but i am not sure how to do this.

    i tried putting in the button click procedure that brings up the main form, a line of code that does frmcheck.txttitle.text = me.txttitle.text but it gives me object must have focus error… so since the control has to have focus i tried to do it in the frmcheck_Load routine, but i got the same error. how can i go about doing this?

    Viewing 3 reply threads
    Author
    Replies
    • #855868

      You could try to leave off the .Text. If you just refer to a text box, you refer to its Value property; this is available if the control doesn’t have the focus.

      • #855899

        hans, i tried this:

        Private Sub Form_Load()
        Me.Title = main.Text71

        End Sub

        text 71 is the main form’s title feild
        i still get an Error saying object required

      • #855900

        hans, i tried this:

        Private Sub Form_Load()
        Me.Title = main.Text71

        End Sub

        text 71 is the main form’s title feild
        i still get an Error saying object required

    • #855869

      You could try to leave off the .Text. If you just refer to a text box, you refer to its Value property; this is available if the control doesn’t have the focus.

    • #855883

      Actually, I would recommend setting the textboxes default value to the main form’s Title entry. That way, if they chose to not enter a record, you won’t have an empty record with the Title in it. It will also carry over to new entries without anymore code involved.

      • #855915

        Hans, i get this error: Object Required (run time error ‘424’)

        and here is the short line of code i’m using to do it:

        Private Sub Form_Load()
        Me.Title = main.Text71

        End Sub

        main.text71 is the text field from the main form

        drew, i also tried what you recommended, but it just doesn’t insert anything, i used the expression builder to get the field: default value “=[Forms]![Master List]![Text71]” (without the quotes)
        doesn’t work for me though. i’m sure its me being dumb, but i don’t see what i’m doing wrong here, or not doing.

        any other suggestions?

        • #855917

          Try
          Me.Title = forms.main.Text71

          • #855923

            Don, that worked! thank you very much!

            is there any explanation on why i had to type in forms.name.text?

            edit: how do you do this if you have a space in the name of the form? ie: Name = “Main Form”

            • #855929

              Forms is the object it was looking for. This is necessary so that it knows what internal class to use. When it goes to obtain the value from your form it needs to call the Forms class and not a Query, Module, or Report class.

            • #855930

              Forms is the object it was looking for. This is necessary so that it knows what internal class to use. When it goes to obtain the value from your form it needs to call the Forms class and not a Query, Module, or Report class.

            • #855931

              forms.[main form].text

            • #855932

              forms.[main form].text

            • #855935

              Don already replied, but also see this very recent thread: post 392057.

            • #856068

              (Edited by HansV to create link to post – use [post#=373999] to create post 373999. See Help 19 for details.)

              You might like to look at post 373999 about 19th May. Hans gave me a great deal of help with this one

              (Sorry I don’t know how to put in a hyperlink)

              Michael Peak

            • #856069

              (Edited by HansV to create link to post – use [post#=373999] to create post 373999. See Help 19 for details.)

              You might like to look at post 373999 about 19th May. Hans gave me a great deal of help with this one

              (Sorry I don’t know how to put in a hyperlink)

              Michael Peak

            • #855936

              Don already replied, but also see this very recent thread: post 392057.

          • #855924

            Don, that worked! thank you very much!

            is there any explanation on why i had to type in forms.name.text?

            edit: how do you do this if you have a space in the name of the form? ie: Name = “Main Form”

        • #855918

          Try
          Me.Title = forms.main.Text71

        • #855941

          On the on Open Event of the form, you would put:

          Me.Title.DefaultValue=Forms(“Main Form”).Text71

          • #855957

            Don, is the method you are describing for VBA? because in the code builder window i get Error 438: Object doesn’t support this property or method, and i’ve used the [ ]’s for expression builder many times because of my poor spacing names.

            Drew, the method you describe doesn’t work for me in the Form_Load or Form_Open events. I don’t get an error, but I don’t see any value in it either.

            Hans, i checked out that other thread and it seems to be more for the expression builder than code builder? i don’t know if its the same syntax or not across the two. But there was a link to a program in that thread that im now thinking about trying to find and replace the spaced names w/ a better formatted one.

            • #855965

              Any way you could post a sample db with those two forms and some data. It would be easier to help that way.

            • #855979

              Its a pretty ugly sample i just made, but it should explain what i mean fine. Type something into the main form ‘Title’ text feild, then click ‘open other form’ button. you should get an error 438 like i keep getting with it. i just want the title textbox text of the first form to appear in the title textbox of the other form.

            • #855990

              I don’t get an error, but the code doesn’t do anything either. Try this (using Drew’s suggestion) in the On Load event of the “other form”:

              Private Sub Form_Load()
              Me.title.DefaultValue = Chr(34) & Forms![Main Form]!title & Chr(34)
              End Sub

              This doesn’t set the value of title, but the default value to be used in new records. Note the use of ! instead of .

            • #856018

              guys, thanks for all your help, but i tried that program from the other post Hans referenced to handle my stupidity. i found and replaced all instances of ‘Main Form’ and replaced it with ‘Main’, now i can call it easily. it seems to have worked, but i didn’t get a chance to check everything yet. as of now i recommend the program too: http://www.rickworld.com/index.html%5B/url%5D

            • #856019

              guys, thanks for all your help, but i tried that program from the other post Hans referenced to handle my stupidity. i found and replaced all instances of ‘Main Form’ and replaced it with ‘Main’, now i can call it easily. it seems to have worked, but i didn’t get a chance to check everything yet. as of now i recommend the program too: http://www.rickworld.com/index.html%5B/url%5D

            • #855991

              I don’t get an error, but the code doesn’t do anything either. Try this (using Drew’s suggestion) in the On Load event of the “other form”:

              Private Sub Form_Load()
              Me.title.DefaultValue = Chr(34) & Forms![Main Form]!title & Chr(34)
              End Sub

              This doesn’t set the value of title, but the default value to be used in new records. Note the use of ! instead of .

            • #856045

              Okay, use this on the Open event.

              Me.title.DefaultValue = “””” & Forms(“Main Form”).title.Value & “”””

              Just a side note. You have a filter set. Is this for data entry, or for data reveiwing? If it is for data entry, I would not use a filter, but instead, set the DataEntry property to true.

            • #856046

              Okay, use this on the Open event.

              Me.title.DefaultValue = “””” & Forms(“Main Form”).title.Value & “”””

              Just a side note. You have a filter set. Is this for data entry, or for data reveiwing? If it is for data entry, I would not use a filter, but instead, set the DataEntry property to true.

            • #855980

              Its a pretty ugly sample i just made, but it should explain what i mean fine. Type something into the main form ‘Title’ text feild, then click ‘open other form’ button. you should get an error 438 like i keep getting with it. i just want the title textbox text of the first form to appear in the title textbox of the other form.

            • #855966

              Any way you could post a sample db with those two forms and some data. It would be easier to help that way.

          • #855958

            Don, is the method you are describing for VBA? because in the code builder window i get Error 438: Object doesn’t support this property or method, and i’ve used the [ ]’s for expression builder many times because of my poor spacing names.

            Drew, the method you describe doesn’t work for me in the Form_Load or Form_Open events. I don’t get an error, but I don’t see any value in it either.

            Hans, i checked out that other thread and it seems to be more for the expression builder than code builder? i don’t know if its the same syntax or not across the two. But there was a link to a program in that thread that im now thinking about trying to find and replace the spaced names w/ a better formatted one.

        • #855942

          On the on Open Event of the form, you would put:

          Me.Title.DefaultValue=Forms(“Main Form”).Text71

      • #855916

        Hans, i get this error: Object Required (run time error ‘424’)

        and here is the short line of code i’m using to do it:

        Private Sub Form_Load()
        Me.Title = main.Text71

        End Sub

        main.text71 is the text field from the main form

        drew, i also tried what you recommended, but it just doesn’t insert anything, i used the expression builder to get the field: default value “=[Forms]![Master List]![Text71]” (without the quotes)
        doesn’t work for me though. i’m sure its me being dumb, but i don’t see what i’m doing wrong here, or not doing.

        any other suggestions?

    • #855884

      Actually, I would recommend setting the textboxes default value to the main form’s Title entry. That way, if they chose to not enter a record, you won’t have an empty record with the Title in it. It will also carry over to new entries without anymore code involved.

    Viewing 3 reply threads
    Reply To: Carrying text feilds across forms (2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: