Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Lounger
    Join Date
    Jul 2005
    Location
    Pennsylvania, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Forms issue (Access2000)

    Using a command button 'Add TaskNOM' (Command49) in a form (frmProjectTaskInfo), I

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Forms issue (Access2000)

    You cannot use a query the way you are attempting to use it in your add form. You have also bound the control in question to <code>=[strMachineJON]</code>, which makes the control non-updateable. You can either directly refer to the controls on the calling form or its child subform, or you can pass the required values in the OpenArgs argument of the DoCmd.OpenForm statement and then parse the values out and handle them in the add form using code. You aren't actually passing lngMachineID, you are setting it as a criteria, so I'm a bit confused as to what you want to do with it on the add form, where presumably the record does not yet exist.
    Charlotte

  3. #3
    Lounger
    Join Date
    Jul 2005
    Location
    Pennsylvania, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms issue (Access2000)

    Sorry about the confusion with the lngMachineID field. The field isn't really needed in the add form but it's value is required when adding the record to the table. I'm going to try your first suggestion as the second one may be a little beyond my VB capabilities. Thanks for your help and I'll let you know if I've had any success.

  4. #4
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Forms issue (Access2000)

    In the event of the command button , create 2 variables and set them to the values of 'lngMachID' and 'strMachineJON' . Then open the form frmProjectAddTasksNOM and then docmd.goto newrecord. Set the value of the control on the new form to those 2 values.
    If you need more help, I will open your example and write the actual code

  5. #5
    Lounger
    Join Date
    Jul 2005
    Location
    Pennsylvania, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms issue (Access2000)

    Thanks Zave. I'll try this as well and see if I can do it. I'll let you know if I need help.

  6. #6
    Lounger
    Join Date
    Jul 2005
    Location
    Pennsylvania, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms issue (Access2000)

    Sorry Zave. I'm not having much success getting this to work on my own. I understand what you suggested by I can't get it coded correctly. I could use your help with the code.

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Forms issue (Access2000)

    If the add form is being opened using the acFormAdd argument, the form should already be on a new record. Also, are you suggesting that the calling form set the values on the add form or that the add form retrieve the values from the variables on the calling form? If the former, then the add form can't be opened as a dialog. If you are suggesting the latter, then the variables need to be module level and public so they can be read from the add form.
    Charlotte

  8. #8
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Forms issue (Access2000)

    See changes in the code behind the button. I hope it is doing what you want. I also included come changes in the form that was opened. If it not what you want, let me know, but I am leaving the computer till tomorrow AM my time.

  9. #9
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Forms issue (Access2000)

    I got rid of the dialog, which solves some of his issues. I had not yet seen his code, so that is why I said to goto a new record. If he wants to do it a different way, we can try that also. Look at what I posted, I am sure there are better ways to do it

  10. #10
    Lounger
    Join Date
    Jul 2005
    Location
    Pennsylvania, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms issue (Access2000)

    Thanks again. I'll take a look at it and try it out. I'll get back to you tomorrow.

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Forms issue (Access2000)

    Yes, I see what you did, and that would do most of what is required. However, opening the add form as a dialog pauses the code in the calling form so that the requery of the subform in the next line doesn't happen until new records have been added. I'm attaching a revised version of the original database that uses a fixed reference to the main form combobox as the default value for the field, allows the add form to remain a dialog, and shows the new records in the main form when the add form is closed. It uses the BeforeInsert method of the add form to set the values in the two fields to the value of the public variables on the main form. I included the strMachineJON value, even though it is set in the default value just to demonstrate another method for setting it.
    Charlotte

  12. #12
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Forms issue (Access2000)

    Sounds good.

  13. #13
    Lounger
    Join Date
    Jul 2005
    Location
    Pennsylvania, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms issue (Access2000)

    Post deleted by rbr

  14. #14
    Lounger
    Join Date
    Jul 2005
    Location
    Pennsylvania, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms issue (Access2000)

    This is great Charlotte! I had implemented Zave's code and was working on the requery to show the updated record in the subform and do exactly what you have done. I couldn't get the add form to refresh the new data in the subform as you have because it requires input from the unbound field strMachineJON in the main form to generate it initially. The requery was being ignored. Is it because of the way you've set the field values to the value of the public variables from the main form that makes this work?

  15. #15
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Forms issue (Access2000)

    The requery works in the model I posted because the add form is opened as a dialog. That means that the requery code in the main form doesn't get executed until you close the add form, at which time the main form continues executing its code and brings in any records just added. That is one of the benefits of opening a popup form as a dialog, you don't have to do extra programming to get that delay.

    Putting the code in the add form to read the public variables from the main form is mostly a matter of style and experience. As a general rule, it is better to have your code be as self-contained as possible, and having one form modify another means that the form being modified no longer controls its own values and behavior. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

Page 1 of 2 12 LastLast

Posting Permissions

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